Custom serialization of extender properties

I'm performing a custom serialization of a designer host, but can't figure out how to serialize extender properties. I.e., if I add a TableLayoutPanel and then some Buttons to the TLP, each Button gets Row, Column, etc properties from the TLP. However these properties don't show up in the Button's PropertyDescriptorCollection from TypeDescriptor.GetProperties().

How can I get at these properties to add them to my serialization code


Answer this question

Custom serialization of extender properties

  • James Nesbitt

    When you call TypeDescriptor.GetProperties() - do you send the instance or the type to that method

    Also, (if you do send the instance) - is it possible that you filter that PropertyDescriptorCollection output by sending an attribute array with the "DesignTimeOnlyAttribute" (it's logical (good) to do so, but is kinda counter productive in this case.)


  • mukilan91

    Good suggestions, thanks!

    In the GetProperties call, I do use the component for the reason given in the docs: "The properties for a component can differ from the properties of a class, because the site can add or remove properties if the component is sited." This likely refers to extender properties.

    You're right, I do filter by DesignTimeOnly, but it seems odd that it would filter out extended properties like Row/Column from the TableLayoutPanel. Can you offer any opinions on that

  • alex china

    It turns out that I can get the TableLayoutPanel extender properties (Row, Column, etc) when I don't filter the attributes, however they are failing a test that I should be making.

    Assume I have the property descriptor (prop) for RowSpan and that I got this through TypeDescriptor.GetProperties(my_button)["RowSpan"]. If I check prop.ShouldSerializeValue(my_button), it always fails regardless of where the button is in the table.

    I'd really rather not put special cases in for properties by name, though a special case for extender properties in general might not be so bad.

    Any ideas

  • Metaferia

    TypeDescriptor reflects on the component's properties. i believe the settings are part of the IExtenderProvider implementor so in your case, the TableLayoutPanel control, it is the one maintaining a list of these property sets (I saw the TableLayoutSettings)


  • MgManoj

    We stumbled into it a while ago: when adding ExtenderProviders using the IExtenderProviderService - they are added without their "IComponent.Site" property, and when checking if a property is DesignTimeOnly it both checks that a "Site" exists and checks the value of the attribute.

    (we ended up adding our ExProvs like a regular component, which sets its "ISite" property correctly)


  • Mauricio hevs

    Well, yeah, but I need to take care of this in the general case for each component and all extender providers.

    It looks like I can use the IExtenderListService interface to find all extender providers in the designer host and then check the CanExtend property on each of them for the component I'm currently serializing. I can then probably get all ProvidePropertyAttributes for each provider and get at the value that way...

    I'll try this out soon and get back with how I faired.

  • Custom serialization of extender properties