System.ComponentModel.TypeDescriptor.CreateProperty C# (CSharp) Method

CreateProperty() public static method

This creates a new property descriptor identical to an existing property descriptor. The new property descriptor has the specified metadata attributes merged with the existing metadata attributes.
public static CreateProperty ( Type componentType, PropertyDescriptor oldPropertyDescriptor ) : PropertyDescriptor
componentType System.Type
oldPropertyDescriptor PropertyDescriptor
return PropertyDescriptor
        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 ReflectPropertyDescriptor 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)];

                ReflectPropertyDescriptor reflectDesc = attr.ExtenderProperty as ReflectPropertyDescriptor;
                if (reflectDesc != null)
                {
                    return new ExtendedPropertyDescriptor(oldPropertyDescriptor, attributes);
                }
            }

            // This is either a normal prop or the caller has changed target classes.
            //
            return new ReflectPropertyDescriptor(componentType, oldPropertyDescriptor, attributes);
        }

Same methods

TypeDescriptor::CreateProperty ( Type componentType, string name, Type type ) : PropertyDescriptor