mscorlib(4.0.0.0) API with additions
Module.cs
4 using System.Security;
7 
8 namespace System.Reflection
9 {
11  [Serializable]
12  [ClassInterface(ClassInterfaceType.None)]
13  [ComDefaultInterface(typeof(_Module))]
14  [ComVisible(true)]
15  [__DynamicallyInvokable]
16  [PermissionSet(SecurityAction.InheritanceDemand, Unrestricted = true)]
18  {
20  public static readonly TypeFilter FilterTypeName;
21 
23  public static readonly TypeFilter FilterTypeNameIgnoreCase;
24 
25  private const BindingFlags DefaultLookup = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public;
26 
29  [__DynamicallyInvokable]
31  {
32  [__DynamicallyInvokable]
33  get
34  {
35  return GetCustomAttributesData();
36  }
37  }
38 
41  public virtual int MDStreamVersion
42  {
43  get
44  {
45  RuntimeModule runtimeModule = this as RuntimeModule;
46  if (runtimeModule != null)
47  {
48  return runtimeModule.MDStreamVersion;
49  }
50  throw new NotImplementedException();
51  }
52  }
53 
57  [__DynamicallyInvokable]
58  public virtual string FullyQualifiedName
59  {
60  [__DynamicallyInvokable]
61  get
62  {
63  throw new NotImplementedException();
64  }
65  }
66 
69  public virtual Guid ModuleVersionId
70  {
71  get
72  {
73  RuntimeModule runtimeModule = this as RuntimeModule;
74  if (runtimeModule != null)
75  {
76  return runtimeModule.ModuleVersionId;
77  }
78  throw new NotImplementedException();
79  }
80  }
81 
84  public virtual int MetadataToken
85  {
86  get
87  {
88  RuntimeModule runtimeModule = this as RuntimeModule;
89  if (runtimeModule != null)
90  {
91  return runtimeModule.MetadataToken;
92  }
93  throw new NotImplementedException();
94  }
95  }
96 
99  public virtual string ScopeName
100  {
101  get
102  {
103  RuntimeModule runtimeModule = this as RuntimeModule;
104  if (runtimeModule != null)
105  {
106  return runtimeModule.ScopeName;
107  }
108  throw new NotImplementedException();
109  }
110  }
111 
114  [__DynamicallyInvokable]
115  public virtual string Name
116  {
117  [__DynamicallyInvokable]
118  get
119  {
120  RuntimeModule runtimeModule = this as RuntimeModule;
121  if (runtimeModule != null)
122  {
123  return runtimeModule.Name;
124  }
125  throw new NotImplementedException();
126  }
127  }
128 
131  [__DynamicallyInvokable]
132  public virtual Assembly Assembly
133  {
134  [__DynamicallyInvokable]
135  get
136  {
137  RuntimeModule runtimeModule = this as RuntimeModule;
138  if (runtimeModule != null)
139  {
140  return runtimeModule.Assembly;
141  }
142  throw new NotImplementedException();
143  }
144  }
145 
148  public ModuleHandle ModuleHandle => GetModuleHandle();
149 
150  static Module()
151  {
152  __Filters _Filters = new __Filters();
153  __Filters _Filters2 = _Filters;
154  FilterTypeName = _Filters2.FilterTypeName;
155  __Filters _Filters3 = _Filters;
156  FilterTypeNameIgnoreCase = _Filters3.FilterTypeNameIgnoreCase;
157  }
158 
164  [__DynamicallyInvokable]
165  public static bool operator ==(Module left, Module right)
166  {
167  if ((object)left == right)
168  {
169  return true;
170  }
171  if ((object)left == null || (object)right == null || left is RuntimeModule || right is RuntimeModule)
172  {
173  return false;
174  }
175  return left.Equals(right);
176  }
177 
183  [__DynamicallyInvokable]
184  public static bool operator !=(Module left, Module right)
185  {
186  return !(left == right);
187  }
188 
193  [__DynamicallyInvokable]
194  public override bool Equals(object o)
195  {
196  return base.Equals(o);
197  }
198 
201  [__DynamicallyInvokable]
202  public override int GetHashCode()
203  {
204  return base.GetHashCode();
205  }
206 
209  [__DynamicallyInvokable]
210  public override string ToString()
211  {
212  return ScopeName;
213  }
214 
218  public virtual object[] GetCustomAttributes(bool inherit)
219  {
220  throw new NotImplementedException();
221  }
222 
231  public virtual object[] GetCustomAttributes(Type attributeType, bool inherit)
232  {
233  throw new NotImplementedException();
234  }
235 
245  public virtual bool IsDefined(Type attributeType, bool inherit)
246  {
247  throw new NotImplementedException();
248  }
249 
253  {
254  throw new NotImplementedException();
255  }
256 
265  public MethodBase ResolveMethod(int metadataToken)
266  {
267  return ResolveMethod(metadataToken, null, null);
268  }
269 
280  public virtual MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
281  {
282  RuntimeModule runtimeModule = this as RuntimeModule;
283  if (runtimeModule != null)
284  {
285  return runtimeModule.ResolveMethod(metadataToken, genericTypeArguments, genericMethodArguments);
286  }
287  throw new NotImplementedException();
288  }
289 
298  public FieldInfo ResolveField(int metadataToken)
299  {
300  return ResolveField(metadataToken, null, null);
301  }
302 
313  public virtual FieldInfo ResolveField(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
314  {
315  RuntimeModule runtimeModule = this as RuntimeModule;
316  if (runtimeModule != null)
317  {
318  return runtimeModule.ResolveField(metadataToken, genericTypeArguments, genericMethodArguments);
319  }
320  throw new NotImplementedException();
321  }
322 
331  public Type ResolveType(int metadataToken)
332  {
333  return ResolveType(metadataToken, null, null);
334  }
335 
346  public virtual Type ResolveType(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
347  {
348  RuntimeModule runtimeModule = this as RuntimeModule;
349  if (runtimeModule != null)
350  {
351  return runtimeModule.ResolveType(metadataToken, genericTypeArguments, genericMethodArguments);
352  }
353  throw new NotImplementedException();
354  }
355 
365  public MemberInfo ResolveMember(int metadataToken)
366  {
367  return ResolveMember(metadataToken, null, null);
368  }
369 
381  public virtual MemberInfo ResolveMember(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
382  {
383  RuntimeModule runtimeModule = this as RuntimeModule;
384  if (runtimeModule != null)
385  {
386  return runtimeModule.ResolveMember(metadataToken, genericTypeArguments, genericMethodArguments);
387  }
388  throw new NotImplementedException();
389  }
390 
398  public virtual byte[] ResolveSignature(int metadataToken)
399  {
400  RuntimeModule runtimeModule = this as RuntimeModule;
401  if (runtimeModule != null)
402  {
403  return runtimeModule.ResolveSignature(metadataToken);
404  }
405  throw new NotImplementedException();
406  }
407 
415  public virtual string ResolveString(int metadataToken)
416  {
417  RuntimeModule runtimeModule = this as RuntimeModule;
418  if (runtimeModule != null)
419  {
420  return runtimeModule.ResolveString(metadataToken);
421  }
422  throw new NotImplementedException();
423  }
424 
428  public virtual void GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine)
429  {
430  RuntimeModule runtimeModule = this as RuntimeModule;
431  if (runtimeModule != null)
432  {
433  runtimeModule.GetPEKind(out peKind, out machine);
434  }
435  throw new NotImplementedException();
436  }
437 
443  [SecurityCritical]
444  public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
445  {
446  throw new NotImplementedException();
447  }
448 
466  [ComVisible(true)]
467  public virtual Type GetType(string className, bool ignoreCase)
468  {
469  return GetType(className, throwOnError: false, ignoreCase);
470  }
471 
487  [ComVisible(true)]
488  public virtual Type GetType(string className)
489  {
490  return GetType(className, throwOnError: false, ignoreCase: false);
491  }
492 
514  [ComVisible(true)]
515  [__DynamicallyInvokable]
516  public virtual Type GetType(string className, bool throwOnError, bool ignoreCase)
517  {
518  throw new NotImplementedException();
519  }
520 
526  public virtual Type[] FindTypes(TypeFilter filter, object filterCriteria)
527  {
528  Type[] types = GetTypes();
529  int num = 0;
530  for (int i = 0; i < types.Length; i++)
531  {
532  if (filter != null && !filter(types[i], filterCriteria))
533  {
534  types[i] = null;
535  }
536  else
537  {
538  num++;
539  }
540  }
541  if (num == types.Length)
542  {
543  return types;
544  }
545  Type[] array = new Type[num];
546  num = 0;
547  for (int j = 0; j < types.Length; j++)
548  {
549  if (types[j] != null)
550  {
551  array[num++] = types[j];
552  }
553  }
554  return array;
555  }
556 
561  public virtual Type[] GetTypes()
562  {
563  throw new NotImplementedException();
564  }
565 
569  public virtual bool IsResource()
570  {
571  RuntimeModule runtimeModule = this as RuntimeModule;
572  if (runtimeModule != null)
573  {
574  return runtimeModule.IsResource();
575  }
576  throw new NotImplementedException();
577  }
578 
581  public FieldInfo[] GetFields()
582  {
583  return GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
584  }
585 
589  public virtual FieldInfo[] GetFields(BindingFlags bindingFlags)
590  {
591  RuntimeModule runtimeModule = this as RuntimeModule;
592  if (runtimeModule != null)
593  {
594  return runtimeModule.GetFields(bindingFlags);
595  }
596  throw new NotImplementedException();
597  }
598 
603  public FieldInfo GetField(string name)
604  {
605  return GetField(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
606  }
607 
613  public virtual FieldInfo GetField(string name, BindingFlags bindingAttr)
614  {
615  RuntimeModule runtimeModule = this as RuntimeModule;
616  if (runtimeModule != null)
617  {
618  return runtimeModule.GetField(name, bindingAttr);
619  }
620  throw new NotImplementedException();
621  }
622 
626  {
627  return GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
628  }
629 
633  public virtual MethodInfo[] GetMethods(BindingFlags bindingFlags)
634  {
635  RuntimeModule runtimeModule = this as RuntimeModule;
636  if (runtimeModule != null)
637  {
638  return runtimeModule.GetMethods(bindingFlags);
639  }
640  throw new NotImplementedException();
641  }
642 
653  public MethodInfo GetMethod(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
654  {
655  if (name == null)
656  {
657  throw new ArgumentNullException("name");
658  }
659  if (types == null)
660  {
661  throw new ArgumentNullException("types");
662  }
663  for (int i = 0; i < types.Length; i++)
664  {
665  if (types[i] == null)
666  {
667  throw new ArgumentNullException("types");
668  }
669  }
670  return GetMethodImpl(name, bindingAttr, binder, callConvention, types, modifiers);
671  }
672 
679  public MethodInfo GetMethod(string name, Type[] types)
680  {
681  if (name == null)
682  {
683  throw new ArgumentNullException("name");
684  }
685  if (types == null)
686  {
687  throw new ArgumentNullException("types");
688  }
689  for (int i = 0; i < types.Length; i++)
690  {
691  if (types[i] == null)
692  {
693  throw new ArgumentNullException("types");
694  }
695  }
696  return GetMethodImpl(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public, null, CallingConventions.Any, types, null);
697  }
698 
704  public MethodInfo GetMethod(string name)
705  {
706  if (name == null)
707  {
708  throw new ArgumentNullException("name");
709  }
710  return GetMethodImpl(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public, null, CallingConventions.Any, null, null);
711  }
712 
723  protected virtual MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
724  {
725  throw new NotImplementedException();
726  }
727 
728  internal virtual ModuleHandle GetModuleHandle()
729  {
730  return ModuleHandle.EmptyHandle;
731  }
732 
736  {
737  throw new NotImplementedException();
738  }
739 
743  void _Module.GetTypeInfoCount(out uint pcTInfo)
744  {
745  throw new NotImplementedException();
746  }
747 
753  void _Module.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
754  {
755  throw new NotImplementedException();
756  }
757 
765  void _Module.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
766  {
767  throw new NotImplementedException();
768  }
769 
780  void _Module.Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
781  {
782  throw new NotImplementedException();
783  }
784  }
785 }
Obtains information about the attributes of a member and provides access to member metadata.
Definition: MemberInfo.cs:14
override int GetHashCode()
Returns the hash code for this instance.
Definition: Module.cs:202
virtual int MDStreamVersion
Gets the metadata stream version.
Definition: Module.cs:42
Performs reflection on a module.
Definition: Module.cs:17
FieldInfo [] GetFields()
Returns the global fields defined on the module.
Definition: Module.cs:581
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
virtual Guid ModuleVersionId
Gets a universally unique identifier (UUID) that can be used to distinguish between two versions of a...
Definition: Module.cs:70
virtual object [] GetCustomAttributes(bool inherit)
Returns all custom attributes.
Definition: Module.cs:218
Discovers the attributes of a method and provides access to method metadata.
Definition: MethodInfo.cs:13
virtual string ScopeName
Gets a string representing the name of the module.
Definition: Module.cs:100
virtual object [] GetCustomAttributes(Type attributeType, bool inherit)
Gets custom attributes of the specified type.
Definition: Module.cs:231
static readonly TypeFilter FilterTypeNameIgnoreCase
A TypeFilter object that filters the list of types defined in this module based upon the name....
Definition: Module.cs:23
Discovers the attributes of a field and provides access to field metadata.
Definition: FieldInfo.cs:15
BindingFlags
Specifies flags that control binding and the way in which the search for members and types is conduct...
Definition: BindingFlags.cs:10
Definition: __Canon.cs:3
ImageFileMachine
Identifies the platform targeted by an executable.
Represents a runtime handle for a module.
Definition: ModuleHandle.cs:12
virtual string FullyQualifiedName
Gets a string representing the fully qualified name and path to this module.
Definition: Module.cs:59
MethodInfo [] GetMethods()
Returns the global methods defined on the module.
Definition: Module.cs:625
Exposes the enumerator, which supports a simple iteration over a collection of a specified type....
Definition: IEnumerable.cs:9
MemberInfo ResolveMember(int metadataToken)
Returns the type or member identified by the specified metadata token.
Definition: Module.cs:365
Describes the source and destination of a given serialized stream, and provides an additional caller-...
virtual Type GetType(string className, bool ignoreCase)
Returns the specified type, searching the module with the specified case sensitivity.
Definition: Module.cs:467
virtual MemberInfo ResolveMember(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
Returns the type or member identified by the specified metadata token, in the context defined by the ...
Definition: Module.cs:381
virtual IEnumerable< CustomAttributeData > CustomAttributes
Gets a collection that contains this module's custom attributes.
Definition: Module.cs:31
Attaches a modifier to parameters so that binding can work with parameter signatures in which the typ...
virtual FieldInfo GetField(string name, BindingFlags bindingAttr)
Returns a field having the specified name and binding attributes.
Definition: Module.cs:613
Exposes the T:System.Reflection.Module class to unmanaged code.
Definition: _Module.cs:11
CallingConventions
Defines the valid calling conventions for a method.
SecurityAction
Specifies the security actions that can be performed using declarative security.
virtual MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
Returns the method implementation in accordance with the specified criteria.
Definition: Module.cs:723
Represents a globally unique identifier (GUID).To browse the .NET Framework source code for this type...
Definition: Guid.cs:14
virtual void GetObjectData(SerializationInfo info, StreamingContext context)
Provides an T:System.Runtime.Serialization.ISerializable implementation for serialized objects.
Definition: Module.cs:444
override bool Equals(object o)
Determines whether this module and the specified object are equal.
Definition: Module.cs:194
virtual byte [] ResolveSignature(int metadataToken)
Returns the signature blob identified by a metadata token.
Definition: Module.cs:398
Represents a collection that can contain many different types of permissions.
virtual Type [] FindTypes(TypeFilter filter, object filterCriteria)
Returns an array of classes accepted by the given filter and filter criteria.
Definition: Module.cs:526
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.
MethodBase ResolveMethod(int metadataToken)
Returns the method or constructor identified by the specified metadata token.
Definition: Module.cs:265
Type ResolveType(int metadataToken)
Returns the type identified by the specified metadata token.
Definition: Module.cs:331
Represents an assembly, which is a reusable, versionable, and self-describing building block of a com...
Definition: Assembly.cs:22
static bool operator !=(Module left, Module right)
Indicates whether two T:System.Reflection.Module objects are not equal.
Definition: Module.cs:184
A platform-specific type that is used to represent a pointer or a handle.
Definition: IntPtr.cs:14
virtual MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
Returns the method or constructor identified by the specified metadata token, in the context defined ...
Definition: Module.cs:280
static bool operator==(Module left, Module right)
Indicates whether two T:System.Reflection.Module objects are equal.
Definition: Module.cs:165
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
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 MethodInfo [] GetMethods(BindingFlags bindingFlags)
Returns the global methods defined on the module that match the specified binding flags.
Definition: Module.cs:633
Selects a member from a list of candidates, and performs type conversion from actual argument type to...
Definition: Binder.cs:10
Stores all the data needed to serialize or deserialize an object. This class cannot be inherited.
virtual FieldInfo [] GetFields(BindingFlags bindingFlags)
Returns the global fields defined on the module that match the specified binding flags.
Definition: Module.cs:589
Represents a collection of objects that can be individually accessed by index.
Definition: IList.cs:9
virtual Type GetType(string className, bool throwOnError, bool ignoreCase)
Returns the specified type, specifying whether to make a case-sensitive search of the module and whet...
Definition: Module.cs:516
virtual string ResolveString(int metadataToken)
Returns the string identified by the specified metadata token.
Definition: Module.cs:415
virtual void GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine)
Gets a pair of values indicating the nature of the code in a module and the platform targeted by the ...
Definition: Module.cs:428
virtual int MetadataToken
Gets a token that identifies the module in metadata.
Definition: Module.cs:85
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...
Allows an object to control its own serialization and deserialization.
Definition: ISerializable.cs:8
virtual FieldInfo ResolveField(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
Returns the field identified by the specified metadata token, in the context defined by the specified...
Definition: Module.cs:313
static readonly TypeFilter FilterTypeName
A TypeFilter object that filters the list of types defined in this module based upon the name....
Definition: Module.cs:20
FieldInfo ResolveField(int metadataToken)
Returns the field identified by the specified metadata token.
Definition: Module.cs:298
virtual Type [] GetTypes()
Returns all the types defined within this module.
Definition: Module.cs:561
PortableExecutableKinds
Identifies the nature of the code in an executable file.
Specifies that the class can be serialized.
FieldInfo GetField(string name)
Returns a field having the specified name.
Definition: Module.cs:603
MethodInfo GetMethod(string name, Type[] types)
Returns a method having the specified name and parameter types.
Definition: Module.cs:679
virtual Type GetType(string className)
Returns the specified type, performing a case-sensitive search.
Definition: Module.cs:488
static readonly ModuleHandle EmptyHandle
Represents an empty module handle.
Definition: ModuleHandle.cs:15
virtual string Name
Gets a String representing the name of the module with the path removed.
Definition: Module.cs:116
MethodInfo GetMethod(string name)
Returns a method having the specified name.
Definition: Module.cs:704
ClassInterfaceType
Identifies the type of class interface that is generated for a class.
Specifies that the parameter is an input parameter.
override string ToString()
Returns the name of the module.
Definition: Module.cs:210
virtual bool IsDefined(Type attributeType, bool inherit)
Returns a value that indicates whether the specified attribute type has been applied to this module.
Definition: Module.cs:245
virtual Type ResolveType(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
Returns the type identified by the specified metadata token, in the context defined by the specified ...
Definition: Module.cs:346
virtual X509Certificate GetSignerCertificate()
Returns an X509Certificate object corresponding to the certificate included in the Authenticode signa...
Definition: Module.cs:735
delegate bool TypeFilter(Type m, object filterCriteria)
Filters the classes represented in an array of T:System.Type objects.
The exception that is thrown when a requested method or operation is not implemented.
MethodInfo GetMethod(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
Returns a method having the specified name, binding information, calling convention,...
Definition: Module.cs:653
Provides methods that help you use X.509 v.3 certificates.
virtual IList< CustomAttributeData > GetCustomAttributesData()
Returns a list of T:System.Reflection.CustomAttributeData objects for the current module,...
Definition: Module.cs:252
Provides custom attributes for reflection objects that support them.
virtual bool IsResource()
Gets a value indicating whether the object is a resource.
Definition: Module.cs:569
void GetTypeInfoCount(out uint pcTInfo)
Retrieves the number of type information interfaces that an object provides (either 0 or 1).