protected virtual void PostFilterProperties(IDictionary properties) { if (this.inheritedProps != null) { if (this.InheritanceAttribute.Equals(System.ComponentModel.InheritanceAttribute.InheritedReadOnly)) { PropertyDescriptor[] array = new PropertyDescriptor[properties.Values.Count]; properties.Values.CopyTo(array, 0); for (int i = 0; i < array.Length; i++) { PropertyDescriptor oldPropertyDescriptor = array[i]; properties[oldPropertyDescriptor.Name] = TypeDescriptor.CreateProperty(oldPropertyDescriptor.ComponentType, oldPropertyDescriptor, new Attribute[] { ReadOnlyAttribute.Yes }); } } else { foreach (DictionaryEntry entry in this.inheritedProps) { InheritedPropertyDescriptor descriptor2 = entry.Value as InheritedPropertyDescriptor; if (descriptor2 != null) { PropertyDescriptor descriptor3 = (PropertyDescriptor)properties[entry.Key]; if (descriptor3 != null) { descriptor2.PropertyDescriptor = descriptor3; properties[entry.Key] = descriptor2; } } } } } }
/// <include file='doc\ComponentDesigner.uex' path='docs/doc[@for="ComponentDesigner.PostFilterProperties"]/*' /> /// <devdoc> /// <para> /// Allows /// a designer to filter the set of properties the /// component it is designing will expose through the /// TypeDescriptor object. /// </para> /// </devdoc> protected virtual void PostFilterProperties(IDictionary properties) { // Check for inheritance // if (inheritedProps != null) { bool readOnlyInherit = (InheritanceAttribute.Equals(InheritanceAttribute.InheritedReadOnly)); if (readOnlyInherit) { // Now loop through all the properties. For each one, try to match a pre-created property. // If that fails, then create a new property. // PropertyDescriptor[] values = new PropertyDescriptor[properties.Values.Count]; properties.Values.CopyTo(values, 0); for (int i = 0; i < values.Length; i++) { PropertyDescriptor prop = values[i]; // This is a private component. Therefore, the user should not be // allowed to modify any properties. We replace all properties with // read-only versions. // properties[prop.Name] = TypeDescriptor.CreateProperty(prop.ComponentType, prop, ReadOnlyAttribute.Yes); } } else { // otherwise apply our inherited properties to the actual property list. // foreach (DictionaryEntry de in inheritedProps) { InheritedPropertyDescriptor inheritedPropDesc = de.Value as InheritedPropertyDescriptor; if (inheritedPropDesc != null) { // replace the property descriptor it was created // with with the new one in case we're shadowing // PropertyDescriptor newInnerProp = (PropertyDescriptor)properties[de.Key]; if (newInnerProp != null) { inheritedPropDesc.PropertyDescriptor = newInnerProp; properties[de.Key] = inheritedPropDesc; } } } } } }