Hi Malain,
DomainTypeDescriptor is currently used to generate code to ADD extra properties to the set exposed on an element (typically seen in the properties grid). You can't use it to override the properties of a base class.
I've raised bugs to this effect, but I don't know whether we'll have time to fix them before V1 now.
You can, however, achieve the same effect in custom code by creating a TypeDescriptionProvider-derived class and attaching it to your derived class. It should return a custom ElementTypeDescriptor-derived class. which has its GetProperties method overridden.
The GetProperties override should call the base GetProperties and then walk the list returned looking for the PropertyDescriptor poining at NamedElement.Name
Replace that PropertyDescriptor instance with your own PropertyDescriptor instance (a class derived from ElementPropertyDescriptor) that has the behavior you want - in this case, you'd return true from IsReadOnly.
A bit long-winded, I'm afraid - this is broadly what the code generator would do for you with a DomainTypeDescriptor. However, using this method does ensure that your objects will behave as you expect in any System.ComponentModel container.
Gareth Jones - Developer - DSL Tools & Software Factories Platform [MSFT] |