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;
32 internal Module () { }
38 public Assembly Assembly {
39 get { return assembly; }
42 public virtual string FullyQualifiedName {
43 get { return fqname; }
50 public string ScopeName {
51 get { return scopename; }
55 public virtual Type[] FindTypes(TypeFilter filter, object filterCriteria)
60 public virtual object[] GetCustomAttributes(bool inherit)
62 return MonoCustomAttrs.GetCustomAttributes (this, inherit);
65 public virtual object[] GetCustomAttributes(Type attributeType, bool inherit)
67 return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
70 public FieldInfo GetField (string name)
75 return GetGlobalType ().GetField (name, BindingFlags.Public | BindingFlags.Static);
78 public FieldInfo GetField (string name, BindingFlags flags)
83 return GetGlobalType ().GetField (name, flags);
86 public FieldInfo[] GetFields ()
89 return new FieldInfo [0];
91 return GetGlobalType ().GetFields (BindingFlags.Public | BindingFlags.Static);
95 public MethodInfo GetMethod (string name)
104 public MethodInfo GetMethod (string name, Type[] types)
113 public MethodInfo GetMethod (string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
122 protected virtual MethodInfo GetMethodImpl (string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
131 public MethodInfo[] GetMethods ()
134 return new MethodInfo [0];
140 public virtual void GetObjectData (SerializationInfo info, StreamingContext context)
144 public X509Certificate GetSignerCertificate ()
147 return X509Certificate.CreateFromSignedFile (assembly.Location);
154 public virtual Type GetType(string className)
156 return GetType (className, false, false);
159 public virtual Type GetType(string className, bool ignoreCase)
161 return GetType (className, false, ignoreCase);
164 public virtual Type GetType(string className, bool throwOnError, bool ignoreCase)
166 if (className == null)
167 throw new ArgumentNullException ("className");
168 if (className == String.Empty)
169 throw new ArgumentException ("Type name can't be empty");
170 return assembly.InternalGetType (this, className, throwOnError, ignoreCase);
173 [MethodImplAttribute (MethodImplOptions.InternalCall)]
174 private extern Type[] InternalGetTypes ();
176 public virtual Type[] GetTypes()
178 return InternalGetTypes ();
181 public virtual bool IsDefined (Type attributeType, bool inherit)
183 return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
186 public bool IsResource()
191 public override string ToString ()
193 return "Reflection.Module: " + name;
196 // Mono Extension: returns the GUID of this module
197 public Guid Mono_GetGuid ()
199 return new Guid (GetGuidInternal ());
202 [MethodImplAttribute (MethodImplOptions.InternalCall)]
203 private extern string GetGuidInternal ();
205 [MethodImplAttribute (MethodImplOptions.InternalCall)]
206 private extern Type GetGlobalType ();
208 [MethodImplAttribute (MethodImplOptions.InternalCall)]
209 private extern void Close ();