2 // System.Reflection/Module.cs
5 // Paolo Molaro (lupus@ximian.com)
7 // (C) 2001 Ximian, Inc. http://www.ximian.com
11 using System.Reflection;
12 using System.Runtime.Serialization;
13 using System.Security.Cryptography.X509Certificates;
14 using System.Runtime.InteropServices;
15 using System.Runtime.CompilerServices;
17 namespace System.Reflection {
20 public class Module : ISerializable, ICustomAttributeProvider {
22 public static readonly TypeFilter FilterTypeName;
23 public static readonly TypeFilter FilterTypeNameIgnoreCase;
25 private IntPtr _impl; /* a pointer to a MonoImage */
26 internal Assembly assembly;
27 internal string fqname;
29 internal string scopename;
30 internal bool is_resource;
34 public Assembly Assembly {
35 get { return assembly; }
38 public virtual string FullyQualifiedName {
39 get { return fqname; }
46 public string ScopeName {
47 get { return scopename; }
51 public virtual Type[] FindTypes(TypeFilter filter, object filterCriteria)
56 public virtual object[] GetCustomAttributes(bool inherit)
58 return MonoCustomAttrs.GetCustomAttributes (this, inherit);
61 public virtual object[] GetCustomAttributes(Type attributeType, bool inherit)
63 return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
66 public FieldInfo GetField (string name)
71 return GetGlobalType ().GetField (name, BindingFlags.Public | BindingFlags.Static);
74 public FieldInfo GetField (string name, BindingFlags flags)
79 return GetGlobalType ().GetField (name, flags);
82 public FieldInfo[] GetFields ()
85 return new FieldInfo [0];
87 return GetGlobalType ().GetFields (BindingFlags.Public | BindingFlags.Static);
91 public MethodInfo GetMethod (string name)
100 public MethodInfo GetMethod (string name, Type[] types)
109 public MethodInfo GetMethod (string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
118 protected virtual MethodInfo GetMethodImpl (string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
127 public MethodInfo[] GetMethods ()
130 return new MethodInfo [0];
136 public virtual void GetObjectData (SerializationInfo info, StreamingContext context)
140 public X509Certificate GetSignerCertificate ()
143 return X509Certificate.CreateFromSignedFile (assembly.Location);
150 public virtual Type GetType(string className)
152 return GetType (className, false, false);
155 public virtual Type GetType(string className, bool ignoreCase)
157 return GetType (className, false, ignoreCase);
160 public virtual Type GetType(string className, bool throwOnError, bool ignoreCase)
162 if (className == null)
163 throw new ArgumentNullException ("className");
164 if (className == String.Empty)
165 throw new ArgumentException ("Type name can't be empty");
166 return assembly.InternalGetType (this, className, throwOnError, ignoreCase);
169 [MethodImplAttribute (MethodImplOptions.InternalCall)]
170 private extern Type[] InternalGetTypes ();
172 public virtual Type[] GetTypes()
174 return InternalGetTypes ();
177 public virtual bool IsDefined (Type attributeType, bool inherit)
179 return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
182 public bool IsResource()
187 public override string ToString ()
189 return "Reflection.Module: " + name;
192 // Mono Extension: returns the GUID of this module
193 public Guid Mono_GetGuid ()
195 return new Guid (GetGuidInternal ());
198 [MethodImplAttribute (MethodImplOptions.InternalCall)]
199 private extern string GetGuidInternal ();
201 [MethodImplAttribute (MethodImplOptions.InternalCall)]
202 private extern Type GetGlobalType ();