public static PropertyDescriptor CreateProperty(Type componentType, PropertyDescriptor oldPropertyDescriptor, params Attribute[] attributes) {
// We must do some special case work here for extended properties. If the old property descriptor is really
// an extender property that is being surfaced on a component as a normal property, then we must
// do work here or else DebugReflectPropertyDescriptor will fail to resolve the get and set methods. We check
// for the necessary ExtenderProvidedPropertyAttribute and if we find it, we create an
// ExtendedPropertyDescriptor instead. We only do this if the component class is the same, since the user
// may want to re-route the property to a different target.
//
if (componentType == oldPropertyDescriptor.ComponentType) {
ExtenderProvidedPropertyAttribute attr = (ExtenderProvidedPropertyAttribute)
oldPropertyDescriptor.Attributes[
typeof(ExtenderProvidedPropertyAttribute)];
if (attr.ExtenderProperty != null) {
return new DebugExtendedPropertyDescriptor((DebugReflectPropertyDescriptor)attr.ExtenderProperty, attr.ReceiverType, attr.Provider, attributes);
}
}
// This is either a normal prop or the caller has changed target classes.
//
return new DebugReflectPropertyDescriptor(componentType, oldPropertyDescriptor, attributes);
}