tags:

views:

473

answers:

1

The MSDN example shows how to use a DataTable to find the propertydescriptor. A DataTable is overkill when all I need to do is store and forward a short string value.

One example looks somewhat sane, it's using TypeDescriptor.GetProperties(this)["afieldnameintheclass"]. This looks correct to me.

The thing that's confusing me is that a similar example uses an attribute, [ConnectionProvider("Web part Connection Provider")], on the public IWebPartField GetWPConnectFieldProvider() function and seems to be referencing that in his GetProperties call (TypeDescriptor.GetProperties(this)["Web part Connection Provider"]).

Is the sane-seeming example correct?

+1  A: 

Yes, I'd gone code-blind.

If the value you wanted to provide to a consumer web part was stored in the field:

string afieldnameintheclass;

You would use the following schema property.

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