How to correctly implement IWebPartField.Schema when providing a string field

The MSDN example shows how to use a DataTable to search for a propertydescriptor. DataTable is redundant when all I have to do is save and forward a short string value.

One example looks somewhat robust, it uses TypeDescriptor.GetProperties (this) ["afieldnameintheclass"]. It looks right to me.

What confuses me is that in a similar example, the [ConnectionProvider ("Web Part Connection Provider")] attribute is used in the public IWebPartField GetWPConnectFieldProvider () function and seems to refer to this in its GetProperties (TypeDescriptor call. GetProperties (this) ["Web Part Connection Provider"]).

Does the correct example look right?

+3
source share
1 answer

Yes, I went blind code.

If the value that you would like to provide to the consumer web part has been stored in the field:

string afieldnameintheclass;

You would use the following schema property.

public PropertyDescriptor Schema {
{
  get
  {
    return TypeDescriptor.GetProperties(this)["afieldnameintheclass"];
  }
}
+2
source

Source: https://habr.com/ru/post/1703899/


All Articles