![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#11
| |||
| |||
|
|
It turns out that in the case where things don't serialize as I expect, the 'defaultValue' private field in InheritedPropertyDescriptor matches the value of the property! |
|
I'm not 100% clear, but it looks like the InheritedPropertyDescriptor object is created each time TypeDescriptor.GetProperties(myObject, false) is called, so that the 'defaultValue' always matches the current property value; therefore, ShouldSerializeValue always returns false... |
#12
| |||
| |||
|
#13
| |||
| |||
|
|
Most everything works properly except in some cases where serialization is concerned, some properties of controls do not get serialized. |
#14
| |||
| |||
|
#15
| |||
| |||
|
#16
| |||
| |||
|
#17
| |||||||
| |||||||
|
|
InheritedPropertyDescriptor is used by the default ComponentDesigner to stand in for properties that are inherited from a base class. This is what I'm seeing, in that the InheritedPropertyDescriptors are used |
|
1. To the root object itself, since you are inheriting from its base class. When you say root object here, are you referring to the designer host's root |
|
2. To fields found in the base class of the root object. Public and protected fields from the base class are added to the designer so they can be manipulated by the user. Ok, so this of course is dependent on my understanding of the earlier |
|
InheritedPropertyDescriptor modifies the default value of properties so the default value is the current value at object instantiation. Yes, this appears to be what is happening. |
|
As the property was inherited from another instance |
|
, the designer must make it so resetting the property value resets it to the value that was set by the inherited class, which may differ from the default value stored in metadata. The designer certainly does seem to set it to something different than what |
|
Hope this helpful to you. Yes, it's a good step forward, although I don't understand everything yet. |
#18
| |||
| |||
|
|
In addition, we should always write a ShouldSerialize<PropertyName> method for each property we'd like to serialize. |
|
We should always use TypeDescriptor.GetProperties(component) in our serializer and call the ShouldSerializeValue method on each property to tell if it should be serialized. |
|
The fact that the component designer is substituting different property descriptors should be invisible to you. |
#19
| |||
| |||
|
|
InheritedPropertyDescriptor modifies the default value of properties so the default value is the current value at object instantiation. As the property was inherited from another instance, the designer must make it so resetting the property value resets it to the value that was set by the inherited class, which may differ from the default value stored in metadata |
#20
| |||
| |||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |