mscorlib(4.0.0.0) API with additions
ParameterInfo.cs
4 using System.Security;
5 
6 namespace System.Reflection
7 {
10  [ClassInterface(ClassInterfaceType.None)]
11  [ComDefaultInterface(typeof(_ParameterInfo))]
12  [ComVisible(true)]
13  [__DynamicallyInvokable]
15  {
17  protected string NameImpl;
18 
20  protected Type ClassImpl;
21 
23  protected int PositionImpl;
24 
27 
29  protected object DefaultValueImpl;
30 
33 
34  [OptionalField]
35  private IntPtr _importer;
36 
37  [OptionalField]
38  private int _token;
39 
40  [OptionalField]
41  private bool bExtraConstChecked;
42 
45  [__DynamicallyInvokable]
46  public virtual Type ParameterType
47  {
48  [__DynamicallyInvokable]
49  get
50  {
51  return ClassImpl;
52  }
53  }
54 
57  [__DynamicallyInvokable]
58  public virtual string Name
59  {
60  [__DynamicallyInvokable]
61  get
62  {
63  return NameImpl;
64  }
65  }
66 
70  [__DynamicallyInvokable]
71  public virtual bool HasDefaultValue
72  {
73  [__DynamicallyInvokable]
74  get
75  {
76  throw new NotImplementedException();
77  }
78  }
79 
82  [__DynamicallyInvokable]
83  public virtual object DefaultValue
84  {
85  [__DynamicallyInvokable]
86  get
87  {
88  throw new NotImplementedException();
89  }
90  }
91 
94  public virtual object RawDefaultValue
95  {
96  get
97  {
98  throw new NotImplementedException();
99  }
100  }
101 
104  [__DynamicallyInvokable]
105  public virtual int Position
106  {
107  [__DynamicallyInvokable]
108  get
109  {
110  return PositionImpl;
111  }
112  }
113 
116  [__DynamicallyInvokable]
117  public virtual ParameterAttributes Attributes
118  {
119  [__DynamicallyInvokable]
120  get
121  {
122  return AttrsImpl;
123  }
124  }
125 
128  [__DynamicallyInvokable]
129  public virtual MemberInfo Member
130  {
131  [__DynamicallyInvokable]
132  get
133  {
134  return MemberImpl;
135  }
136  }
137 
141  [__DynamicallyInvokable]
142  public bool IsIn
143  {
144  [__DynamicallyInvokable]
145  get
146  {
147  return (Attributes & ParameterAttributes.In) != ParameterAttributes.None;
148  }
149  }
150 
154  [__DynamicallyInvokable]
155  public bool IsOut
156  {
157  [__DynamicallyInvokable]
158  get
159  {
160  return (Attributes & ParameterAttributes.Out) != ParameterAttributes.None;
161  }
162  }
163 
167  [__DynamicallyInvokable]
168  public bool IsLcid
169  {
170  [__DynamicallyInvokable]
171  get
172  {
173  return (Attributes & ParameterAttributes.Lcid) != ParameterAttributes.None;
174  }
175  }
176 
180  [__DynamicallyInvokable]
181  public bool IsRetval
182  {
183  [__DynamicallyInvokable]
184  get
185  {
186  return (Attributes & ParameterAttributes.Retval) != ParameterAttributes.None;
187  }
188  }
189 
193  [__DynamicallyInvokable]
194  public bool IsOptional
195  {
196  [__DynamicallyInvokable]
197  get
198  {
199  return (Attributes & ParameterAttributes.Optional) != ParameterAttributes.None;
200  }
201  }
202 
205  public virtual int MetadataToken => (this as RuntimeParameterInfo)?.MetadataToken ?? 134217728;
206 
209  [__DynamicallyInvokable]
211  {
212  [__DynamicallyInvokable]
213  get
214  {
215  return GetCustomAttributesData();
216  }
217  }
218 
220  protected ParameterInfo()
221  {
222  }
223 
224  internal void SetName(string name)
225  {
226  NameImpl = name;
227  }
228 
229  internal void SetAttributes(ParameterAttributes attributes)
230  {
231  AttrsImpl = attributes;
232  }
233 
236  public virtual Type[] GetRequiredCustomModifiers()
237  {
238  return EmptyArray<Type>.Value;
239  }
240 
243  public virtual Type[] GetOptionalCustomModifiers()
244  {
245  return EmptyArray<Type>.Value;
246  }
247 
250  [__DynamicallyInvokable]
251  public override string ToString()
252  {
253  return ParameterType.FormatTypeName() + " " + Name;
254  }
255 
260  [__DynamicallyInvokable]
261  public virtual object[] GetCustomAttributes(bool inherit)
262  {
263  return EmptyArray<object>.Value;
264  }
265 
274  [__DynamicallyInvokable]
275  public virtual object[] GetCustomAttributes(Type attributeType, bool inherit)
276  {
277  if (attributeType == null)
278  {
279  throw new ArgumentNullException("attributeType");
280  }
281  return EmptyArray<object>.Value;
282  }
283 
293  [__DynamicallyInvokable]
294  public virtual bool IsDefined(Type attributeType, bool inherit)
295  {
296  if (attributeType == null)
297  {
298  throw new ArgumentNullException("attributeType");
299  }
300  return false;
301  }
302 
306  {
307  throw new NotImplementedException();
308  }
309 
313  void _ParameterInfo.GetTypeInfoCount(out uint pcTInfo)
314  {
315  throw new NotImplementedException();
316  }
317 
323  void _ParameterInfo.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
324  {
325  throw new NotImplementedException();
326  }
327 
335  void _ParameterInfo.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
336  {
337  throw new NotImplementedException();
338  }
339 
350  void _ParameterInfo.Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
351  {
352  throw new NotImplementedException();
353  }
354 
359  [SecurityCritical]
360  public object GetRealObject(StreamingContext context)
361  {
362  if (MemberImpl == null)
363  {
364  throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState"));
365  }
366  ParameterInfo[] array = null;
367  switch (MemberImpl.MemberType)
368  {
369  case MemberTypes.Constructor:
370  case MemberTypes.Method:
371  if (PositionImpl == -1)
372  {
373  if (MemberImpl.MemberType == MemberTypes.Method)
374  {
375  return ((MethodInfo)MemberImpl).ReturnParameter;
376  }
377  throw new SerializationException(Environment.GetResourceString("Serialization_BadParameterInfo"));
378  }
379  array = ((MethodBase)MemberImpl).GetParametersNoCopy();
380  if (array != null && PositionImpl < array.Length)
381  {
382  return array[PositionImpl];
383  }
384  throw new SerializationException(Environment.GetResourceString("Serialization_BadParameterInfo"));
385  case MemberTypes.Property:
386  array = ((RuntimePropertyInfo)MemberImpl).GetIndexParametersNoCopy();
387  if (array != null && PositionImpl > -1 && PositionImpl < array.Length)
388  {
389  return array[PositionImpl];
390  }
391  throw new SerializationException(Environment.GetResourceString("Serialization_BadParameterInfo"));
392  default:
393  throw new SerializationException(Environment.GetResourceString("Serialization_NoParameterInfo"));
394  }
395  }
396  }
397 }
Obtains information about the attributes of a member and provides access to member metadata.
Definition: MemberInfo.cs:14
virtual Type [] GetOptionalCustomModifiers()
Gets the optional custom modifiers of the parameter.
Discovers the attributes of a parameter and provides access to parameter metadata.
ParameterAttributes AttrsImpl
The attributes of the parameter.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
virtual Type [] GetRequiredCustomModifiers()
Gets the required custom modifiers of the parameter.
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...
Discovers the attributes of a method and provides access to method metadata.
Definition: MethodInfo.cs:13
Indicates that the current interface implementer is a reference to another object.
int PositionImpl
The zero-based position of the parameter in the parameter list.
Definition: __Canon.cs:3
override string ToString()
Gets the parameter type and name represented as a string.
virtual object RawDefaultValue
Gets a value indicating the default value if the parameter has a default value.
virtual MemberInfo Member
Gets a value indicating the member in which the parameter is implemented.
bool IsIn
Gets a value indicating whether this is an input parameter.
Exposes the enumerator, which supports a simple iteration over a collection of a specified type....
Definition: IEnumerable.cs:9
virtual object [] GetCustomAttributes(bool inherit)
Gets all the custom attributes defined on this parameter.
MemberInfo MemberImpl
The member in which the field is implemented.
Describes the source and destination of a given serialized stream, and provides an additional caller-...
object GetRealObject(StreamingContext context)
Returns the real object that should be deserialized instead of the object that the serialized stream ...
bool IsOptional
Gets a value indicating whether this parameter is optional.
virtual bool HasDefaultValue
Gets a value that indicates whether this parameter has a default value.
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
virtual IList< CustomAttributeData > GetCustomAttributesData()
Returns a list of T:System.Reflection.CustomAttributeData objects for the current parameter,...
virtual object DefaultValue
Gets a value indicating the default value if the parameter has a default value.
object DefaultValueImpl
The default value of the parameter.
A platform-specific type that is used to represent a pointer or a handle.
Definition: IntPtr.cs:14
ParameterInfo()
Initializes a new instance of the ParameterInfo class.
bool IsRetval
Gets a value indicating whether this is a Retval parameter.
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
Provides information about methods and constructors.
Definition: MethodBase.cs:19
The exception thrown when an error occurs during serialization or deserialization.
ParameterAttributes
Defines the attributes that can be associated with a parameter. These are defined in CorHdr....
virtual int MetadataToken
Gets a value that identifies this parameter in metadata.
string NameImpl
The name of the parameter.
Represents a collection of objects that can be individually accessed by index.
Definition: IList.cs:9
virtual int Position
Gets the zero-based position of the parameter in the formal parameter list.
bool IsOut
Gets a value indicating whether this is an output parameter.
Specifies that the class can be serialized.
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.
virtual Type ParameterType
Gets the Type of this parameter.
abstract MemberTypes MemberType
When overridden in a derived class, gets a T:System.Reflection.MemberTypes value indicating the type ...
Definition: MemberInfo.cs:19
Type ClassImpl
The Type of the parameter.
void GetTypeInfoCount(out uint pcTInfo)
Retrieves the number of type information interfaces that an object provides (either 0 or 1).
ClassInterfaceType
Identifies the type of class interface that is generated for a class.
Specifies that the parameter is an input parameter.
virtual ParameterAttributes Attributes
Gets the attributes for this parameter.
virtual bool IsDefined(Type attributeType, bool inherit)
Determines whether the custom attribute of the specified type or its derived types is applied to this...
bool IsLcid
Gets a value indicating whether this parameter is a locale identifier (lcid).
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.
MemberTypes
Marks each type of member that is defined as a derived class of T:System.Reflection....
Definition: MemberTypes.cs:9
Exposes the T:System.Reflection.ParameterInfo class to unmanaged code.
The exception that is thrown when a requested method or operation is not implemented.
virtual string Name
Gets the name of the parameter.
virtual object [] GetCustomAttributes(Type attributeType, bool inherit)
Gets the custom attributes of the specified type or its derived types that are applied to this parame...
virtual IEnumerable< CustomAttributeData > CustomAttributes
Gets a collection that contains this parameter's custom attributes.
Provides custom attributes for reflection objects that support them.