mscorlib(4.0.0.0) API with additions
PropertyInfo.cs
1 using System.Diagnostics;
5 
6 namespace System.Reflection
7 {
10  [ClassInterface(ClassInterfaceType.None)]
11  [ComDefaultInterface(typeof(_PropertyInfo))]
12  [ComVisible(true)]
13  [__DynamicallyInvokable]
14  [PermissionSet(SecurityAction.InheritanceDemand, Name = "FullTrust")]
15  public abstract class PropertyInfo : MemberInfo, _PropertyInfo
16  {
19  public override MemberTypes MemberType => MemberTypes.Property;
20 
23  [__DynamicallyInvokable]
24  public abstract Type PropertyType
25  {
26  [__DynamicallyInvokable]
27  get;
28  }
29 
32  [__DynamicallyInvokable]
33  public abstract PropertyAttributes Attributes
34  {
35  [__DynamicallyInvokable]
36  get;
37  }
38 
42  [__DynamicallyInvokable]
43  public abstract bool CanRead
44  {
45  [__DynamicallyInvokable]
46  get;
47  }
48 
52  [__DynamicallyInvokable]
53  public abstract bool CanWrite
54  {
55  [__DynamicallyInvokable]
56  get;
57  }
58 
61  [__DynamicallyInvokable]
62  public virtual MethodInfo GetMethod
63  {
64  [__DynamicallyInvokable]
65  get
66  {
67  return GetGetMethod(nonPublic: true);
68  }
69  }
70 
73  [__DynamicallyInvokable]
74  public virtual MethodInfo SetMethod
75  {
76  [__DynamicallyInvokable]
77  get
78  {
79  return GetSetMethod(nonPublic: true);
80  }
81  }
82 
86  [__DynamicallyInvokable]
87  public bool IsSpecialName
88  {
89  [__DynamicallyInvokable]
90  get
91  {
92  return (Attributes & PropertyAttributes.SpecialName) != PropertyAttributes.None;
93  }
94  }
95 
101  [__DynamicallyInvokable]
102  public static bool operator ==(PropertyInfo left, PropertyInfo right)
103  {
104  if ((object)left == right)
105  {
106  return true;
107  }
108  if ((object)left == null || (object)right == null || left is RuntimePropertyInfo || right is RuntimePropertyInfo)
109  {
110  return false;
111  }
112  return left.Equals(right);
113  }
114 
120  [__DynamicallyInvokable]
121  public static bool operator !=(PropertyInfo left, PropertyInfo right)
122  {
123  return !(left == right);
124  }
125 
130  [__DynamicallyInvokable]
131  public override bool Equals(object obj)
132  {
133  return base.Equals(obj);
134  }
135 
138  [__DynamicallyInvokable]
139  public override int GetHashCode()
140  {
141  return base.GetHashCode();
142  }
143 
148  [__DynamicallyInvokable]
149  public virtual object GetConstantValue()
150  {
151  throw new NotImplementedException();
152  }
153 
158  public virtual object GetRawConstantValue()
159  {
160  throw new NotImplementedException();
161  }
162 
176  public abstract void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture);
177 
181  [__DynamicallyInvokable]
182  public abstract MethodInfo[] GetAccessors(bool nonPublic);
183 
188  [__DynamicallyInvokable]
189  public abstract MethodInfo GetGetMethod(bool nonPublic);
190 
200  [__DynamicallyInvokable]
201  public abstract MethodInfo GetSetMethod(bool nonPublic);
202 
205  [__DynamicallyInvokable]
206  public abstract ParameterInfo[] GetIndexParameters();
207 
211  [DebuggerStepThrough]
212  [DebuggerHidden]
213  [__DynamicallyInvokable]
214  public object GetValue(object obj)
215  {
216  return GetValue(obj, null);
217  }
218 
230  [DebuggerStepThrough]
231  [DebuggerHidden]
232  [__DynamicallyInvokable]
233  public virtual object GetValue(object obj, object[] index)
234  {
235  return GetValue(obj, BindingFlags.Default, null, index, null);
236  }
237 
250  public abstract object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture);
251 
262  [DebuggerStepThrough]
263  [DebuggerHidden]
264  [__DynamicallyInvokable]
265  public void SetValue(object obj, object value)
266  {
267  SetValue(obj, value, null);
268  }
269 
282  [DebuggerStepThrough]
283  [DebuggerHidden]
284  [__DynamicallyInvokable]
285  public virtual void SetValue(object obj, object value, object[] index)
286  {
287  SetValue(obj, value, BindingFlags.Default, null, index, null);
288  }
289 
292  public virtual Type[] GetRequiredCustomModifiers()
293  {
294  return EmptyArray<Type>.Value;
295  }
296 
299  public virtual Type[] GetOptionalCustomModifiers()
300  {
301  return EmptyArray<Type>.Value;
302  }
303 
306  [__DynamicallyInvokable]
308  {
309  return GetAccessors(nonPublic: false);
310  }
311 
314  [__DynamicallyInvokable]
316  {
317  return GetGetMethod(nonPublic: false);
318  }
319 
322  [__DynamicallyInvokable]
324  {
325  return GetSetMethod(nonPublic: false);
326  }
327 
331  {
332  return GetType();
333  }
334 
338  void _PropertyInfo.GetTypeInfoCount(out uint pcTInfo)
339  {
340  throw new NotImplementedException();
341  }
342 
348  void _PropertyInfo.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
349  {
350  throw new NotImplementedException();
351  }
352 
360  void _PropertyInfo.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
361  {
362  throw new NotImplementedException();
363  }
364 
375  void _PropertyInfo.Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
376  {
377  throw new NotImplementedException();
378  }
379  }
380 }
Obtains information about the attributes of a member and provides access to member metadata.
Definition: MemberInfo.cs:14
Discovers the attributes of a parameter and provides access to parameter metadata.
object GetValue(object obj)
Returns the property value of a specified object.
Discovers the attributes of a method and provides access to method metadata.
Definition: MethodInfo.cs:13
void GetTypeInfoCount(out uint pcTInfo)
Retrieves the number of type information interfaces that an object provides (either 0 or 1).
virtual Type [] GetRequiredCustomModifiers()
Returns an array of types representing the required custom modifiers of the property.
virtual object GetConstantValue()
Returns a literal value associated with the property by a compiler.
virtual MethodInfo GetMethod
Gets the get accessor for this property.
Definition: PropertyInfo.cs:63
BindingFlags
Specifies flags that control binding and the way in which the search for members and types is conduct...
Definition: BindingFlags.cs:10
virtual MethodInfo SetMethod
Gets the set accessor for this property.
Definition: PropertyInfo.cs:75
Definition: __Canon.cs:3
virtual object GetValue(object obj, object[] index)
Returns the property value of a specified object with optional index values for indexed properties.
MethodInfo [] GetAccessors()
Returns an array whose elements reflect the public get and set accessors of the property reflected by...
override int GetHashCode()
Returns the hash code for this instance.
void SetValue(object obj, object value)
Sets the property value of a specified object.
void GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
Maps a set of names to a corresponding set of dispatch identifiers.
SecurityAction
Specifies the security actions that can be performed using declarative security.
abstract PropertyAttributes Attributes
Gets the attributes for this property.
Definition: PropertyInfo.cs:34
void GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
Retrieves the type information for an object, which can be used to get the type information for an in...
void Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
Provides access to properties and methods exposed by an object.
static bool operator==(PropertyInfo left, PropertyInfo right)
Indicates whether two T:System.Reflection.PropertyInfo objects are equal.
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
Exposes the public members of the T:System.Reflection.PropertyInfo class to unmanaged code.
MethodInfo GetSetMethod()
Returns the public set accessor for this property.
override MemberTypes MemberType
Gets a T:System.Reflection.MemberTypes value indicating that this member is a property.
Definition: PropertyInfo.cs:19
static bool operator !=(PropertyInfo left, PropertyInfo right)
Indicates whether two T:System.Reflection.PropertyInfo objects are not equal.
abstract Type PropertyType
Gets the type of this property.
Definition: PropertyInfo.cs:25
virtual Type [] GetOptionalCustomModifiers()
Returns an array of types representing the optional custom modifiers of the property.
Selects a member from a list of candidates, and performs type conversion from actual argument type to...
Definition: Binder.cs:10
Discovers the attributes of a property and provides access to property metadata.
Definition: PropertyInfo.cs:15
new Type GetType()
Provides COM objects with version-independent access to the M:System.Object.GetType method.
abstract ParameterInfo [] GetIndexParameters()
When overridden in a derived class, returns an array of all the index parameters for the property.
PropertyAttributes
Defines the attributes that can be associated with a property. These attribute values are defined in ...
virtual object GetRawConstantValue()
Returns a literal value associated with the property by a compiler.
Specifies that the class can be serialized.
ClassInterfaceType
Identifies the type of class interface that is generated for a class.
Specifies that the parameter is an input parameter.
abstract bool CanWrite
Gets a value indicating whether the property can be written to.
Definition: PropertyInfo.cs:54
override bool Equals(object obj)
Returns a value that indicates whether this instance is equal to a specified object.
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition: CultureInfo.cs:16
abstract void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
When overridden in a derived class, sets the property value for a specified object that has the speci...
MemberTypes
Marks each type of member that is defined as a derived class of T:System.Reflection....
Definition: MemberTypes.cs:9
virtual void SetValue(object obj, object value, object[] index)
Sets the property value of a specified object with optional index values for index properties.
The exception that is thrown when a requested method or operation is not implemented.
bool IsSpecialName
Gets a value indicating whether the property is the special name.
Definition: PropertyInfo.cs:88
abstract bool CanRead
Gets a value indicating whether the property can be read.
Definition: PropertyInfo.cs:44
MethodInfo GetGetMethod()
Returns the public get accessor for this property.