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;
}
}
}
}
}