27using System.ComponentModel;
32#if !CompactFramework && !WindowsCE && !PocketPC && !XBOX360 && !SILVERLIGHT && !WINDOWS_PHONE && !NETFX_CORE
33 public class AdvPropertyDescriptor : PropertyDescriptor, ICustomTypeDescriptor, IEquatable<AdvPropertyDescriptor>
37 if (
property ==
null) {
throw new ArgumentNullException(
"property"); }
38 return (Attribute[])
property.GetCustomAttributes(typeof(Attribute),
true);
52 this.description = base.Description;
62 this.description = base.Description;
66 get {
return info.DeclaringType; }
68 public override object GetValue(
object component)
70 if (component is PropertyDescriptor)
72 Object result = ((PropertyDescriptor)component).GetValue(
null);
77 return property.GetValue(component,
null);
79 return field.GetValue(component);
83 get {
return property !=
null && !
property.CanWrite; }
91 return property.PropertyType;
93 return field.FieldType;
99 throw new NotSupportedException();
101 public override void SetValue(
object component,
object value)
105 property.SetValue(component, value,
null);
109 field.SetValue(component, value);
111 this.OnValueChanged(component, EventArgs.Empty);
119 return info.GetHashCode();
142 #region ICustomTypeDescriptor Members
143 AttributeCollection ICustomTypeDescriptor.GetAttributes()
147 string ICustomTypeDescriptor.GetClassName()
151 string ICustomTypeDescriptor.GetComponentName()
155 TypeConverter ICustomTypeDescriptor.GetConverter()
159 EventDescriptor ICustomTypeDescriptor.GetDefaultEvent()
163 PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty()
167 object ICustomTypeDescriptor.GetEditor(Type editorBaseType)
172 EventDescriptorCollection ICustomTypeDescriptor.GetEvents()
174 return EventDescriptorCollection.Empty;
176 EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes)
178 return EventDescriptorCollection.Empty;
181 PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties()
183 return TypeDescriptor.GetConverter(
ComponentType).GetProperties(
null);
185 PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
187 return TypeDescriptor.GetConverter(
ComponentType).GetProperties(
null,
null, attributes);
189 object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd)
void SetDescription(string value)
AttributeCollection ICustomTypeDescriptor. GetAttributes()
static Attribute[] GetAttributes(MemberInfo property)
AdvPropertyDescriptor(string name, PropertyInfo property)
AdvPropertyDescriptor(PropertyInfo property)
AdvPropertyDescriptor(FieldInfo field)
AdvPropertyDescriptor(string name, FieldInfo field)
bool Equals(AdvPropertyDescriptor other)
override void SetValue(object component, object value)
override bool CanResetValue(object component)
override bool Equals(object obj)
override Type ComponentType
override int GetHashCode()
override object GetValue(object component)
override string Description
override void ResetValue(object component)
override Type PropertyType
override bool ShouldSerializeValue(object component)