2003-10-17 Pedro Mart�nez Juli� <yoros@wanadoo.es>
[mono.git] / mcs / class / corlib / System.Reflection / Module.cs
1 //
2 // System.Reflection/Module.cs
3 //
4 // Author:
5 //   Paolo Molaro (lupus@ximian.com)
6 //
7 // (C) 2001 Ximian, Inc.  http://www.ximian.com
8 //
9
10 using System;
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;
16
17 namespace System.Reflection {
18
19         [Serializable]
20         public class Module : ISerializable, ICustomAttributeProvider {
21         
22                 public static readonly TypeFilter FilterTypeName;
23                 public static readonly TypeFilter FilterTypeNameIgnoreCase;
24         
25                 private IntPtr _impl; /* a pointer to a MonoImage */
26                 internal Assembly assembly;
27                 internal string fqname;
28                 internal string name;
29                 internal string scopename;
30                 internal bool is_resource;
31         
32                 internal Module () {}
33         
34                 public Assembly Assembly {
35                         get { return assembly; }
36                 }
37         
38                 public virtual string FullyQualifiedName {
39                         get { return fqname; }
40                 }
41         
42                 public string Name {
43                         get { return name; }
44                 }
45         
46                 public string ScopeName {
47                         get { return scopename; }
48                 }
49         
50                 [MonoTODO]
51                 public virtual Type[] FindTypes(TypeFilter filter, object filterCriteria) 
52                 {
53                         return null;
54                 }
55         
56                 [MonoTODO]
57                 public virtual object[] GetCustomAttributes(bool inherit) 
58                 {
59                         return MonoCustomAttrs.GetCustomAttributes (this, inherit);
60                 }
61         
62                 [MonoTODO]
63                 public virtual object[] GetCustomAttributes(Type attributeType, bool inherit) 
64                 {
65                         return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
66                 }
67         
68                 public FieldInfo GetField (string name) 
69                 {
70                         if (IsResource ())
71                                 return null;
72
73                         return GetGlobalType ().GetField (name, BindingFlags.Public | BindingFlags.Static);
74                 }
75         
76                 public FieldInfo GetField (string name, BindingFlags flags) 
77                 {
78                         if (IsResource ())
79                                 return null;
80
81                         return GetGlobalType ().GetField (name, flags);
82                 }
83         
84                 public FieldInfo[] GetFields () 
85                 {
86                         if (IsResource ())
87                                 return new FieldInfo [0];
88
89                         return GetGlobalType ().GetFields (BindingFlags.Public | BindingFlags.Static);
90                 }
91         
92                 [MonoTODO]
93                 public MethodInfo GetMethod (string name) 
94                 {
95                         if (IsResource ())
96                                 return null;
97
98                         return null;
99                 }
100         
101                 [MonoTODO]
102                 public MethodInfo GetMethod (string name, Type[] types) 
103                 {
104                         if (IsResource ())
105                                 return null;
106
107                         return null;
108                 }
109         
110                 [MonoTODO]
111                 public MethodInfo GetMethod (string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) 
112                 {
113                         if (IsResource ())
114                                 return null;
115
116                         return null;
117                 }
118         
119                 [MonoTODO]
120                 protected virtual MethodInfo GetMethodImpl (string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) 
121                 {
122                         if (IsResource ())
123                                 return null;
124
125                         return null;
126                 }
127         
128                 [MonoTODO]
129                 public MethodInfo[] GetMethods () 
130                 {
131                         if (IsResource ())
132                                 return new MethodInfo [0];
133
134                         return null;
135                 }
136         
137                 [MonoTODO]
138                 public virtual void GetObjectData (SerializationInfo info, StreamingContext context) 
139                 {
140                 }
141         
142                 public X509Certificate GetSignerCertificate ()
143                 {
144                         try {
145                                 return X509Certificate.CreateFromSignedFile (assembly.Location);
146                         }
147                         catch {
148                                 return null;
149                         }
150                 }
151         
152                 [MonoTODO]
153                 public virtual Type GetType(string className) 
154                 {
155                         return null;
156                 }
157         
158                 [MonoTODO]
159                 public virtual Type GetType(string className, bool ignoreCase) 
160                 {
161                         return null;
162                 }
163         
164                 [MonoTODO]
165                 public virtual Type GetType(string className, bool throwOnError, bool ignoreCase) 
166                 {
167                         return null;
168                 }
169         
170                 [MonoTODO]
171                 public virtual Type[] GetTypes() 
172                 {
173                         return null;
174                 }
175         
176                 [MonoTODO]
177                 public virtual bool IsDefined (Type attributeType, bool inherit) 
178                 {
179                         return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
180                 }
181         
182                 public bool IsResource() 
183                 {
184                         return is_resource;
185                 }
186         
187                 [MonoTODO]
188                 public override string ToString () 
189                 {
190                         return "Reflection.Module: " + name;
191                 }
192
193                 // Mono Extension: returns the GUID of this module
194                 public Guid Mono_GetGuid ()
195                 {
196                         return new Guid (GetGuidInternal ());
197                 }
198
199                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
200                 private extern string GetGuidInternal ();
201
202                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
203                 private extern Type GetGlobalType ();
204         }
205 }