System.ComponentModel.DebugReflectPropertyDescriptor.DebugReflectPropertyDescriptor C# (CSharp) Method

DebugReflectPropertyDescriptor() public method

public DebugReflectPropertyDescriptor ( Type componentClass, PropertyDescriptor oldReflectPropertyDescriptor, Attribute attributes ) : System.Runtime.Serialization.Formatters
componentClass System.Type
oldReflectPropertyDescriptor PropertyDescriptor
attributes System.Attribute
return System.Runtime.Serialization.Formatters
        public DebugReflectPropertyDescriptor(Type componentClass, PropertyDescriptor oldReflectPropertyDescriptor, Attribute[] attributes)
        : base(oldReflectPropertyDescriptor, attributes) {
        
            this.componentClass = componentClass;
            this.type = oldReflectPropertyDescriptor.PropertyType;

            if (componentClass == null) {
                throw new ArgumentException(SR.GetString(SR.InvalidNullArgument, "componentClass"));
            }

            // If the classes are the same, we can potentially optimize the method fetch because
            // the old property descriptor may already have it.
            //
            if (oldReflectPropertyDescriptor is DebugReflectPropertyDescriptor) {
                DebugReflectPropertyDescriptor oldProp = (DebugReflectPropertyDescriptor)oldReflectPropertyDescriptor;
                
                if (oldProp.ComponentType == componentClass) {
                    propInfo = oldProp.propInfo;
                    getMethod = oldProp.getMethod;
                    setMethod = oldProp.setMethod;
                    shouldSerializeMethod = oldProp.shouldSerializeMethod;
                    resetMethod = oldProp.resetMethod;
                    defaultValue = oldProp.defaultValue;
                    ambientValue = oldProp.ambientValue;
                    state = oldProp.state;
                }
                
                // Now we must figure out what to do with our default value.  First, check to see
                // if the caller has provided an new default value attribute.  If so, use it.  Otherwise,
                // just let it be and it will be picked up on demand.
                //
                if (attributes != null) {
                    foreach(Attribute a in attributes) {
                        if (a is DefaultValueAttribute) {
                            defaultValue = ((DefaultValueAttribute)a).Value;
                            state[BitDefaultValueQueried] = true;
                        }
                        else if (a is AmbientValueAttribute) {
                            ambientValue = ((AmbientValueAttribute)a).Value;
                            state[BitAmbientValueQueried] = true;
                        }
                    }
                }
            }
        }

Same methods

DebugReflectPropertyDescriptor::DebugReflectPropertyDescriptor ( Type componentClass, string name, Type type, Attribute attributes ) : System.Runtime.Serialization.Formatters
DebugReflectPropertyDescriptor::DebugReflectPropertyDescriptor ( Type componentClass, string name, Type type, PropertyInfo propInfo, MethodInfo getMethod, MethodInfo setMethod, Attribute attrs ) : System.Runtime.Serialization.Formatters
DebugReflectPropertyDescriptor::DebugReflectPropertyDescriptor ( Type componentClass, string name, Type type, Type receiverType, MethodInfo getMethod, MethodInfo setMethod, Attribute attrs ) : System.Runtime.Serialization.Formatters