using System;
using System.Collections;
using System.Reflection;
using System.Runtime.InteropServices;
namespace System.ComponentModel
{
/// Provides an abstraction of a property on a class.
// Token: 0x020000B5 RID: 181
[ComVisible(true)]
public abstract class PropertyDescriptor : MemberDescriptor
{
/// Initializes a new instance of the class with the name and attributes in the specified .
/// A that contains the name of the property and its attributes.
// Token: 0x060005D2 RID: 1490 RVA: 0x0000F018 File Offset: 0x0000D218
protected PropertyDescriptor(MemberDescriptor reference)
: base(reference)
{
}
/// Initializes a new instance of the class with the name in the specified and the attributes in both the and the array.
/// A containing the name of the member and its attributes.
/// An array containing the attributes you want to associate with the property.
// Token: 0x060005D3 RID: 1491 RVA: 0x0000F024 File Offset: 0x0000D224
protected PropertyDescriptor(MemberDescriptor reference, Attribute[] attrs)
: base(reference, attrs)
{
}
/// Initializes a new instance of the class with the specified name and attributes.
/// The name of the property.
/// An array of type that contains the property attributes.
// Token: 0x060005D4 RID: 1492 RVA: 0x0000F030 File Offset: 0x0000D230
protected PropertyDescriptor(string name, Attribute[] attrs)
: base(name, attrs)
{
}
/// When overridden in a derived class, gets the type of the component this property is bound to.
/// A that represents the type of component this property is bound to. When the or methods are invoked, the object specified might be an instance of this type.
// Token: 0x17000186 RID: 390
// (get) Token: 0x060005D5 RID: 1493
public abstract Type ComponentType { get; }
/// Gets the type converter for this property.
/// A that is used to convert the of this property.
///
///
///
// Token: 0x17000187 RID: 391
// (get) Token: 0x060005D6 RID: 1494 RVA: 0x0000F03C File Offset: 0x0000D23C
public virtual TypeConverter Converter
{
get
{
if (this.converter == null && this.PropertyType != null)
{
TypeConverterAttribute typeConverterAttribute = (TypeConverterAttribute)this.Attributes[typeof(TypeConverterAttribute)];
if (typeConverterAttribute != null && typeConverterAttribute != TypeConverterAttribute.Default)
{
Type typeFromName = this.GetTypeFromName(typeConverterAttribute.ConverterTypeName);
if (typeFromName != null && typeof(TypeConverter).IsAssignableFrom(typeFromName))
{
this.converter = (TypeConverter)this.CreateInstance(typeFromName);
}
}
if (this.converter == null)
{
this.converter = TypeDescriptor.GetConverter(this.PropertyType);
}
}
return this.converter;
}
}
/// Gets a value indicating whether this property should be localized, as specified in the .
/// true if the member is marked with the set to true; otherwise, false.
// Token: 0x17000188 RID: 392
// (get) Token: 0x060005D7 RID: 1495 RVA: 0x0000F0E8 File Offset: 0x0000D2E8
public virtual bool IsLocalizable
{
get
{
foreach (Attribute attribute in this.AttributeArray)
{
if (attribute is LocalizableAttribute)
{
return ((LocalizableAttribute)attribute).IsLocalizable;
}
}
return false;
}
}
/// When overridden in a derived class, gets a value indicating whether this property is read-only.
/// true if the property is read-only; otherwise, false.
// Token: 0x17000189 RID: 393
// (get) Token: 0x060005D8 RID: 1496
public abstract bool IsReadOnly { get; }
/// When overridden in a derived class, gets the type of the property.
/// A that represents the type of the property.
// Token: 0x1700018A RID: 394
// (get) Token: 0x060005D9 RID: 1497
public abstract Type PropertyType { get; }
/// Gets a value indicating whether value change notifications for this property may originate from outside the property descriptor.
/// true if value change notifications may originate from outside the property descriptor; otherwise, false.
// Token: 0x1700018B RID: 395
// (get) Token: 0x060005DA RID: 1498 RVA: 0x0000F12C File Offset: 0x0000D32C
public virtual bool SupportsChangeEvents
{
get
{
return false;
}
}
/// Gets a value indicating whether this property should be serialized, as specified in the .
/// One of the enumeration values that specifies whether this property should be serialized.
// Token: 0x1700018C RID: 396
// (get) Token: 0x060005DB RID: 1499 RVA: 0x0000F130 File Offset: 0x0000D330
public DesignerSerializationVisibility SerializationVisibility
{
get
{
foreach (Attribute attribute in this.AttributeArray)
{
if (attribute is DesignerSerializationVisibilityAttribute)
{
DesignerSerializationVisibilityAttribute designerSerializationVisibilityAttribute = (DesignerSerializationVisibilityAttribute)attribute;
return designerSerializationVisibilityAttribute.Visibility;
}
}
return DesignerSerializationVisibility.Visible;
}
}
/// Enables other objects to be notified when this property changes.
/// The component to add the handler for.
/// The delegate to add as a listener.
///
/// or is null.
// Token: 0x060005DC RID: 1500 RVA: 0x0000F178 File Offset: 0x0000D378
public virtual void AddValueChanged(object component, EventHandler handler)
{
if (component == null)
{
throw new ArgumentNullException("component");
}
if (handler == null)
{
throw new ArgumentNullException("handler");
}
if (this.notifiers == null)
{
this.notifiers = new Hashtable();
}
EventHandler eventHandler = (EventHandler)this.notifiers[component];
if (eventHandler != null)
{
eventHandler = (EventHandler)Delegate.Combine(eventHandler, handler);
this.notifiers[component] = eventHandler;
}
else
{
this.notifiers[component] = handler;
}
}
/// Enables other objects to be notified when this property changes.
/// The component to remove the handler for.
/// The delegate to remove as a listener.
///
/// or is null.
// Token: 0x060005DD RID: 1501 RVA: 0x0000F204 File Offset: 0x0000D404
public virtual void RemoveValueChanged(object component, EventHandler handler)
{
if (component == null)
{
throw new ArgumentNullException("component");
}
if (handler == null)
{
throw new ArgumentNullException("handler");
}
if (this.notifiers == null)
{
return;
}
EventHandler eventHandler = (EventHandler)this.notifiers[component];
eventHandler = (EventHandler)Delegate.Remove(eventHandler, handler);
if (eventHandler == null)
{
this.notifiers.Remove(component);
}
else
{
this.notifiers[component] = eventHandler;
}
}
/// Adds the attributes of the to the specified list of attributes in the parent class.
/// An that lists the attributes in the parent class. Initially, this is empty.
// Token: 0x060005DE RID: 1502 RVA: 0x0000F284 File Offset: 0x0000D484
protected override void FillAttributes(IList attributeList)
{
base.FillAttributes(attributeList);
}
/// This method returns the object that should be used during invocation of members.
/// The that should be used during invocation of members.
/// The of the invocation target.
/// The potential invocation target.
// Token: 0x060005DF RID: 1503 RVA: 0x0000F290 File Offset: 0x0000D490
protected override object GetInvocationTarget(Type type, object instance)
{
if (type == null)
{
throw new ArgumentNullException("type");
}
if (instance == null)
{
throw new ArgumentNullException("instance");
}
if (instance is CustomTypeDescriptor)
{
CustomTypeDescriptor customTypeDescriptor = (CustomTypeDescriptor)instance;
return customTypeDescriptor.GetPropertyOwner(this);
}
return base.GetInvocationTarget(type, instance);
}
/// Retrieves the current set of ValueChanged event handlers for a specific component
/// A combined multicast event handler, or null if no event handlers are currently assigned to .
/// The component for which to retrieve event handlers.
// Token: 0x060005E0 RID: 1504 RVA: 0x0000F2E4 File Offset: 0x0000D4E4
protected internal EventHandler GetValueChangedHandler(object component)
{
if (component == null || this.notifiers == null)
{
return null;
}
return (EventHandler)this.notifiers[component];
}
/// Raises the ValueChanged event that you implemented.
/// The object that raises the event.
/// An that contains the event data.
// Token: 0x060005E1 RID: 1505 RVA: 0x0000F318 File Offset: 0x0000D518
protected virtual void OnValueChanged(object component, EventArgs e)
{
if (this.notifiers == null)
{
return;
}
EventHandler eventHandler = (EventHandler)this.notifiers[component];
if (eventHandler == null)
{
return;
}
eventHandler(component, e);
}
/// When overridden in a derived class, gets the current value of the property on a component.
/// The value of a property for a given component.
/// The component with the property for which to retrieve the value.
// Token: 0x060005E2 RID: 1506
public abstract object GetValue(object component);
/// When overridden in a derived class, sets the value of the component to a different value.
/// The component with the property value that is to be set.
/// The new value.
// Token: 0x060005E3 RID: 1507
public abstract void SetValue(object component, object value);
/// When overridden in a derived class, resets the value for this property of the component to the default value.
/// The component with the property value that is to be reset to the default value.
// Token: 0x060005E4 RID: 1508
public abstract void ResetValue(object component);
/// When overridden in a derived class, returns whether resetting an object changes its value.
/// true if resetting the component changes its value; otherwise, false.
/// The component to test for reset capability.
// Token: 0x060005E5 RID: 1509
public abstract bool CanResetValue(object component);
/// When overridden in a derived class, determines a value indicating whether the value of this property needs to be persisted.
/// true if the property should be persisted; otherwise, false.
/// The component with the property to be examined for persistence.
// Token: 0x060005E6 RID: 1510
public abstract bool ShouldSerializeValue(object component);
/// Creates an instance of the specified type.
/// A new instance of the type.
/// A that represents the type to create.
// Token: 0x060005E7 RID: 1511 RVA: 0x0000F354 File Offset: 0x0000D554
protected object CreateInstance(Type type)
{
if (type == null || this.PropertyType == null)
{
return null;
}
Type[] array = new Type[] { typeof(Type) };
ConstructorInfo constructor = type.GetConstructor(array);
object obj;
if (constructor != null)
{
object[] array2 = new object[] { this.PropertyType };
obj = TypeDescriptor.CreateInstance(null, type, array, array2);
}
else
{
obj = TypeDescriptor.CreateInstance(null, type, null, null);
}
return obj;
}
/// Compares this to another object to see if they are equivalent.
/// true if the values are equivalent; otherwise, false.
/// The object to compare to this .
// Token: 0x060005E8 RID: 1512 RVA: 0x0000F3C4 File Offset: 0x0000D5C4
public override bool Equals(object obj)
{
if (!base.Equals(obj))
{
return false;
}
PropertyDescriptor propertyDescriptor = obj as PropertyDescriptor;
return propertyDescriptor != null && propertyDescriptor.PropertyType == this.PropertyType;
}
/// Returns the default .
/// A .
///
///
///
// Token: 0x060005E9 RID: 1513 RVA: 0x0000F3FC File Offset: 0x0000D5FC
public PropertyDescriptorCollection GetChildProperties()
{
return this.GetChildProperties(null, null);
}
/// Returns a for a given object.
/// A with the properties for the specified component.
/// A component to get the properties for.
// Token: 0x060005EA RID: 1514 RVA: 0x0000F408 File Offset: 0x0000D608
public PropertyDescriptorCollection GetChildProperties(object instance)
{
return this.GetChildProperties(instance, null);
}
/// Returns a using a specified array of attributes as a filter.
/// A with the properties that match the specified attributes.
/// An array of type to use as a filter.
// Token: 0x060005EB RID: 1515 RVA: 0x0000F414 File Offset: 0x0000D614
public PropertyDescriptorCollection GetChildProperties(Attribute[] filter)
{
return this.GetChildProperties(null, filter);
}
/// Returns the hash code for this object.
/// The hash code for this object.
// Token: 0x060005EC RID: 1516 RVA: 0x0000F420 File Offset: 0x0000D620
public override int GetHashCode()
{
return base.GetHashCode();
}
/// Returns a for a given object using a specified array of attributes as a filter.
/// A with the properties that match the specified attributes for the specified component.
/// A component to get the properties for.
/// An array of type to use as a filter.
// Token: 0x060005ED RID: 1517 RVA: 0x0000F428 File Offset: 0x0000D628
public virtual PropertyDescriptorCollection GetChildProperties(object instance, Attribute[] filter)
{
return TypeDescriptor.GetProperties(instance, filter);
}
/// Gets an editor of the specified type.
/// An instance of the requested editor type, or null if an editor cannot be found.
/// The base type of editor, which is used to differentiate between multiple editors that a property supports.
// Token: 0x060005EE RID: 1518 RVA: 0x0000F434 File Offset: 0x0000D634
public virtual object GetEditor(Type editorBaseType)
{
Type type = null;
Attribute[] attributeArray = this.AttributeArray;
if (attributeArray != null && attributeArray.Length != 0)
{
foreach (Attribute attribute in attributeArray)
{
EditorAttribute editorAttribute = attribute as EditorAttribute;
if (editorAttribute != null)
{
type = this.GetTypeFromName(editorAttribute.EditorTypeName);
if (type != null && type.IsSubclassOf(editorBaseType))
{
break;
}
}
}
}
object obj = null;
if (type != null)
{
obj = this.CreateInstance(type);
}
if (obj == null)
{
obj = TypeDescriptor.GetEditor(this.PropertyType, editorBaseType);
}
return obj;
}
/// Returns a type using its name.
/// A that matches the given type name, or null if a match cannot be found.
/// The assembly-qualified name of the type to retrieve.
// Token: 0x060005EF RID: 1519 RVA: 0x0000F4DC File Offset: 0x0000D6DC
protected Type GetTypeFromName(string typeName)
{
if (typeName == null || this.ComponentType == null || typeName.Trim().Length == 0)
{
return null;
}
Type type = Type.GetType(typeName);
if (type == null)
{
int num = typeName.IndexOf(",");
if (num != -1)
{
typeName = typeName.Substring(0, num);
}
type = this.ComponentType.Assembly.GetType(typeName);
}
return type;
}
// Token: 0x040001BE RID: 446
private TypeConverter converter;
// Token: 0x040001BF RID: 447
private Hashtable notifiers;
}
}