using System;
using System.Collections;
using System.ComponentModel.Design;
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
namespace System.ComponentModel
{
/// Represents a class member, such as a property or event. This is an abstract base class.
// Token: 0x020000AC RID: 172
[ComVisible(true)]
public abstract class MemberDescriptor
{
/// Initializes a new instance of the class with the specified name of the member and an array of attributes.
/// The name of the member.
/// An array of type that contains the member attributes.
/// The name is an empty string ("") or null.
// Token: 0x0600058C RID: 1420 RVA: 0x0000E6C4 File Offset: 0x0000C8C4
protected MemberDescriptor(string name, Attribute[] attrs)
{
this.name = name;
this.attrs = attrs;
}
/// Initializes a new instance of the class with the name in the specified and the attributes in both the old and the array.
/// A that has the name of the member and its attributes.
/// An array of objects with the attributes you want to add to the member.
// Token: 0x0600058D RID: 1421 RVA: 0x0000E6DC File Offset: 0x0000C8DC
protected MemberDescriptor(MemberDescriptor reference, Attribute[] attrs)
{
this.name = reference.name;
this.attrs = attrs;
}
/// Initializes a new instance of the class with the specified name of the member.
/// The name of the member.
/// The name is an empty string ("") or null.
// Token: 0x0600058E RID: 1422 RVA: 0x0000E6F8 File Offset: 0x0000C8F8
protected MemberDescriptor(string name)
{
this.name = name;
}
/// Initializes a new instance of the class with the specified .
/// A that contains the name of the member and its attributes.
// Token: 0x0600058F RID: 1423 RVA: 0x0000E708 File Offset: 0x0000C908
protected MemberDescriptor(MemberDescriptor reference)
{
this.name = reference.name;
this.attrs = reference.AttributeArray;
}
/// Gets or sets an array of attributes.
/// An array of type that contains the attributes of this member.
// Token: 0x17000173 RID: 371
// (get) Token: 0x06000590 RID: 1424 RVA: 0x0000E728 File Offset: 0x0000C928
// (set) Token: 0x06000591 RID: 1425 RVA: 0x0000E7E8 File Offset: 0x0000C9E8
protected virtual Attribute[] AttributeArray
{
get
{
ArrayList arrayList = new ArrayList();
if (this.attrs != null)
{
arrayList.AddRange(this.attrs);
}
this.FillAttributes(arrayList);
Hashtable hashtable = new Hashtable();
foreach (object obj in arrayList)
{
Attribute attribute = (Attribute)obj;
hashtable[attribute.TypeId] = attribute;
}
Attribute[] array = new Attribute[hashtable.Values.Count];
hashtable.Values.CopyTo(array, 0);
return array;
}
set
{
this.attrs = value;
}
}
/// When overridden in a derived class, adds the attributes of the inheriting class to the specified list of attributes in the parent class.
/// An that lists the attributes in the parent class. Initially, this is empty.
// Token: 0x06000592 RID: 1426 RVA: 0x0000E7F4 File Offset: 0x0000C9F4
protected virtual void FillAttributes(IList attributeList)
{
}
/// Gets the collection of attributes for this member.
/// An that provides the attributes for this member, or an empty collection if there are no attributes in the .
// Token: 0x17000174 RID: 372
// (get) Token: 0x06000593 RID: 1427 RVA: 0x0000E7F8 File Offset: 0x0000C9F8
public virtual AttributeCollection Attributes
{
get
{
if (this.attrCollection == null)
{
this.attrCollection = this.CreateAttributeCollection();
}
return this.attrCollection;
}
}
/// Creates a collection of attributes using the array of attributes passed to the constructor.
/// A new that contains the attributes.
// Token: 0x06000594 RID: 1428 RVA: 0x0000E818 File Offset: 0x0000CA18
protected virtual AttributeCollection CreateAttributeCollection()
{
return new AttributeCollection(this.AttributeArray);
}
/// Gets the name of the category to which the member belongs, as specified in the .
/// The name of the category to which the member belongs. If there is no , the category name is set to the default category, Misc.
///
///
///
// Token: 0x17000175 RID: 373
// (get) Token: 0x06000595 RID: 1429 RVA: 0x0000E828 File Offset: 0x0000CA28
public virtual string Category
{
get
{
return ((CategoryAttribute)this.Attributes[typeof(CategoryAttribute)]).Category;
}
}
/// Gets the description of the member, as specified in the .
/// The description of the member. If there is no , the property value is set to the default, which is an empty string ("").
// Token: 0x17000176 RID: 374
// (get) Token: 0x06000596 RID: 1430 RVA: 0x0000E84C File Offset: 0x0000CA4C
public virtual string Description
{
get
{
foreach (Attribute attribute in this.AttributeArray)
{
if (attribute is DescriptionAttribute)
{
return ((DescriptionAttribute)attribute).Description;
}
}
return string.Empty;
}
}
/// Gets whether this member should be set only at design time, as specified in the .
/// true if this member should be set only at design time; false if the member can be set during run time.
// Token: 0x17000177 RID: 375
// (get) Token: 0x06000597 RID: 1431 RVA: 0x0000E894 File Offset: 0x0000CA94
public virtual bool DesignTimeOnly
{
get
{
foreach (Attribute attribute in this.AttributeArray)
{
if (attribute is DesignOnlyAttribute)
{
return ((DesignOnlyAttribute)attribute).IsDesignOnly;
}
}
return false;
}
}
/// Gets the name that can be displayed in a window, such as a Properties window.
/// The name to display for the member.
// Token: 0x17000178 RID: 376
// (get) Token: 0x06000598 RID: 1432 RVA: 0x0000E8D8 File Offset: 0x0000CAD8
public virtual string DisplayName
{
get
{
foreach (Attribute attribute in this.AttributeArray)
{
if (attribute is DisplayNameAttribute)
{
return ((DisplayNameAttribute)attribute).DisplayName;
}
}
return this.name;
}
}
/// Gets the name of the member.
/// The name of the member.
// Token: 0x17000179 RID: 377
// (get) Token: 0x06000599 RID: 1433 RVA: 0x0000E924 File Offset: 0x0000CB24
public virtual string Name
{
get
{
return this.name;
}
}
/// Gets a value indicating whether the member is browsable, as specified in the .
/// true if the member is browsable; otherwise, false. If there is no , the property value is set to the default, which is true.
// Token: 0x1700017A RID: 378
// (get) Token: 0x0600059A RID: 1434 RVA: 0x0000E92C File Offset: 0x0000CB2C
public virtual bool IsBrowsable
{
get
{
foreach (Attribute attribute in this.AttributeArray)
{
if (attribute is BrowsableAttribute)
{
return ((BrowsableAttribute)attribute).Browsable;
}
}
return true;
}
}
/// Gets the hash code for the name of the member, as specified in .
/// The hash code for the name of the member.
// Token: 0x1700017B RID: 379
// (get) Token: 0x0600059B RID: 1435 RVA: 0x0000E970 File Offset: 0x0000CB70
protected virtual int NameHashCode
{
get
{
return this.name.GetHashCode();
}
}
/// Returns the hash code for this instance.
/// A hash code for the current .
// Token: 0x0600059C RID: 1436 RVA: 0x0000E980 File Offset: 0x0000CB80
public override int GetHashCode()
{
return base.GetHashCode();
}
/// Compares this instance to the given object to see if they are equivalent.
/// true if equivalent; otherwise, false.
/// The object to compare to the current instance.
// Token: 0x0600059D RID: 1437 RVA: 0x0000E988 File Offset: 0x0000CB88
public override bool Equals(object obj)
{
MemberDescriptor memberDescriptor = obj as MemberDescriptor;
return memberDescriptor != null && memberDescriptor.name == this.name;
}
/// Gets a component site for the given component.
/// The site of the component, or null if a site does not exist.
/// The component for which you want to find a site.
// Token: 0x0600059E RID: 1438 RVA: 0x0000E9B8 File Offset: 0x0000CBB8
protected static ISite GetSite(object component)
{
if (component is Component)
{
return ((Component)component).Site;
}
return null;
}
/// Gets the component on which to invoke a method.
/// An instance of the component to invoke. This method returns a visual designer when the property is attached to a visual designer.
/// A representing the type of component this is bound to. For example, if this describes a property, this parameter should be the class that the property is declared on.
/// An instance of the object to call.
///
/// or is null.
// Token: 0x0600059F RID: 1439 RVA: 0x0000E9D4 File Offset: 0x0000CBD4
[Obsolete("Use GetInvocationTarget")]
protected static object GetInvokee(Type componentClass, object component)
{
if (component is IComponent)
{
ISite site = ((IComponent)component).Site;
if (site != null && site.DesignMode)
{
global::System.ComponentModel.Design.IDesignerHost designerHost = site.GetService(typeof(global::System.ComponentModel.Design.IDesignerHost)) as global::System.ComponentModel.Design.IDesignerHost;
if (designerHost != null)
{
global::System.ComponentModel.Design.IDesigner designer = designerHost.GetDesigner((IComponent)component);
if (designer != null && componentClass.IsInstanceOfType(designer))
{
component = designer;
}
}
}
}
return component;
}
/// Retrieves the object that should be used during invocation of members.
/// The object to be used during member invocations.
/// The of the invocation target.
/// The potential invocation target.
///
/// or is null.
// Token: 0x060005A0 RID: 1440 RVA: 0x0000EA48 File Offset: 0x0000CC48
protected virtual object GetInvocationTarget(Type type, object instance)
{
if (type == null)
{
throw new ArgumentNullException("type");
}
if (instance == null)
{
throw new ArgumentNullException("instance");
}
return MemberDescriptor.GetInvokee(type, instance);
}
/// Finds the given method through reflection, searching only for public methods.
/// A that represents the method, or null if the method is not found.
/// The component that contains the method.
/// The name of the method to find.
/// An array of parameters for the method, used to choose between overloaded methods.
/// The type to return for the method.
// Token: 0x060005A1 RID: 1441 RVA: 0x0000EA74 File Offset: 0x0000CC74
protected static MethodInfo FindMethod(Type componentClass, string name, Type[] args, Type returnType)
{
return MemberDescriptor.FindMethod(componentClass, name, args, returnType, true);
}
/// Finds the given method through reflection, with an option to search only public methods.
/// A that represents the method, or null if the method is not found.
/// The component that contains the method.
/// The name of the method to find.
/// An array of parameters for the method, used to choose between overloaded methods.
/// The type to return for the method.
/// Whether to restrict search to public methods.
// Token: 0x060005A2 RID: 1442 RVA: 0x0000EA80 File Offset: 0x0000CC80
protected static MethodInfo FindMethod(Type componentClass, string name, Type[] args, Type returnType, bool publicOnly)
{
BindingFlags bindingFlags;
if (publicOnly)
{
bindingFlags = BindingFlags.Public;
}
else
{
bindingFlags = BindingFlags.Public | BindingFlags.NonPublic;
}
return componentClass.GetMethod(name, bindingFlags, null, CallingConventions.Any, args, null);
}
// Token: 0x1700017C RID: 380
// (get) Token: 0x060005A3 RID: 1443 RVA: 0x0000EAAC File Offset: 0x0000CCAC
internal static IComparer DefaultComparer
{
get
{
if (MemberDescriptor.default_comparer == null)
{
MemberDescriptor.default_comparer = new MemberDescriptor.MemberDescriptorComparer();
}
return MemberDescriptor.default_comparer;
}
}
// Token: 0x040001A8 RID: 424
private string name;
// Token: 0x040001A9 RID: 425
private Attribute[] attrs;
// Token: 0x040001AA RID: 426
private AttributeCollection attrCollection;
// Token: 0x040001AB RID: 427
private static IComparer default_comparer;
// Token: 0x020000AD RID: 173
private class MemberDescriptorComparer : IComparer
{
// Token: 0x060005A5 RID: 1445 RVA: 0x0000EAD0 File Offset: 0x0000CCD0
public int Compare(object x, object y)
{
return string.Compare(((MemberDescriptor)x).Name, ((MemberDescriptor)y).Name, false, CultureInfo.InvariantCulture);
}
}
}
}