3 // Copyright(c) Microsoft Corporation. All rights reserved.
6 // <OWNER>Microsoft</OWNER>
9 namespace System
.Reflection
12 using System
.Collections
.Generic
;
13 using System
.Diagnostics
.Contracts
;
15 using System
.Runtime
.InteropServices
;
16 using System
.Security
.Permissions
;
19 [ClassInterface(ClassInterfaceType
.None
)]
20 [ComDefaultInterface(typeof(_MemberInfo
))]
21 #pragma warning disable 618
22 [PermissionSetAttribute(SecurityAction
.InheritanceDemand
, Name
= "FullTrust")]
23 #pragma warning restore 618
24 [System
.Runtime
.InteropServices
.ComVisible(true)]
26 [ContractClass(typeof(MemberInfoContracts
))]
28 public abstract class MemberInfo
: ICustomAttributeProvider
, _MemberInfo
31 protected MemberInfo() { }
34 #region Internal Methods
35 internal virtual bool CacheEquals(object o
) { throw new NotImplementedException(); }
38 #region Public Abstract\Virtual Members
39 public abstract MemberTypes MemberType { get; }
41 public abstract String Name { get; }
43 public abstract Type DeclaringType { get; }
45 public abstract Type ReflectedType { get; }
47 public virtual IEnumerable
<CustomAttributeData
> CustomAttributes
51 return GetCustomAttributesData();
54 public abstract Object
[] GetCustomAttributes(bool inherit
);
56 public abstract Object
[] GetCustomAttributes(Type attributeType
, bool inherit
);
58 public abstract bool IsDefined(Type attributeType
, bool inherit
);
60 public virtual IList
<CustomAttributeData
> GetCustomAttributesData()
62 throw new NotImplementedException();
66 public virtual extern int MetadataToken
{
67 [System
.Runtime
.CompilerServices
.MethodImplAttribute (System
.Runtime
.CompilerServices
.MethodImplOptions
.InternalCall
)]
71 public virtual int MetadataToken { get { throw new InvalidOperationException(); }
}
74 public virtual Module Module
79 return ((Type
)this).Module
;
81 throw new NotImplementedException();
90 public static bool operator ==(MemberInfo left
, MemberInfo right
)
92 if (ReferenceEquals(left
, right
))
95 if ((object)left
== null || (object)right
== null)
99 MethodBase method1
, method2
;
100 FieldInfo field1
, field2
;
101 EventInfo event1
, event2
;
102 PropertyInfo property1
, property2
;
104 if ((type1
= left
as Type
) != null && (type2
= right
as Type
) != null)
105 return type1
== type2
;
106 else if ((method1
= left
as MethodBase
) != null && (method2
= right
as MethodBase
) != null)
107 return method1
== method2
;
108 else if ((field1
= left
as FieldInfo
) != null && (field2
= right
as FieldInfo
) != null)
109 return field1
== field2
;
110 else if ((event1
= left
as EventInfo
) != null && (event2
= right
as EventInfo
) != null)
111 return event1
== event2
;
112 else if ((property1
= left
as PropertyInfo
) != null && (property2
= right
as PropertyInfo
) != null)
113 return property1
== property2
;
118 public static bool operator !=(MemberInfo left
, MemberInfo right
)
120 return !(left
== right
);
122 #endif // !FEATURE_CORECLR
124 public override bool Equals(object obj
)
126 return base.Equals(obj
);
129 public override int GetHashCode()
131 return base.GetHashCode();
135 // this method is required so Object.GetType is not made final virtual by the compiler
136 Type _MemberInfo
.GetType()
138 return base.GetType();
141 void _MemberInfo
.GetTypeInfoCount(out uint pcTInfo
)
143 throw new NotImplementedException();
146 void _MemberInfo
.GetTypeInfo(uint iTInfo
, uint lcid
, IntPtr ppTInfo
)
148 throw new NotImplementedException();
151 void _MemberInfo
.GetIDsOfNames([In
] ref Guid riid
, IntPtr rgszNames
, uint cNames
, uint lcid
, IntPtr rgDispId
)
153 throw new NotImplementedException();
156 void _MemberInfo
.Invoke(uint dispIdMember
, [In
] ref Guid riid
, uint lcid
, short wFlags
, IntPtr pDispParams
, IntPtr pVarResult
, IntPtr pExcepInfo
, IntPtr puArgErr
)
158 throw new NotImplementedException();
164 [ContractClassFor(typeof(MemberInfo
))]
165 internal abstract class MemberInfoContracts
: MemberInfo
167 public override String Name
{
169 Contract
.Ensures(Contract
.Result
<String
>() != null);
170 return default(String
);
174 #endif // CONTRACTS_FULL