Thu May 23 17:18:46 CEST 2002 Paolo Molaro <lupus@ximian.com>
[mono.git] / mcs / class / corlib / System.Reflection / Assembly.cs
1 //
2 // System.Reflection/Assembly.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.Security.Policy;
12 using System.Runtime.Serialization;
13 using System.Reflection.Emit;
14 using System.IO;
15 using System.Globalization;
16 using System.Runtime.CompilerServices;
17
18 namespace System.Reflection {
19
20         [Serializable]
21         public class Assembly : System.Reflection.ICustomAttributeProvider,
22                 System.Security.IEvidenceFactory, System.Runtime.Serialization.ISerializable {
23                 private IntPtr _mono_assembly;
24
25                 internal Assembly () {}
26
27                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
28                 private extern string get_code_base ();
29                 
30                 public virtual string CodeBase {
31                         get {
32                                 return get_code_base ();
33                         }
34                 }
35
36                 internal virtual string CopiedCodeBase {
37                         get {
38                                 return null;
39                         }
40                 } 
41
42                 public virtual string FullName {
43                         get {
44                                 //
45                                 // FIXME: This is wrong, but it gets us going
46                                 // in the compiler for now
47                                 //
48                                 return CodeBase;
49                         }
50                 }
51
52                 public virtual MethodInfo EntryPoint {
53                         get {
54                                 return null;
55                         }
56                 }
57
58                 public virtual Evidence Evidence {
59                         get {
60                                 return null;
61                         }
62                 }
63
64                 public virtual String Location {
65                         get {
66                                 return null;
67                         }
68                 }
69
70                 public virtual void GetObjectData (SerializationInfo info, StreamingContext context)
71                 {
72                 }
73
74                 public virtual bool IsDefined (Type attributeType, bool inherit)
75                 {
76                         return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
77                 }
78
79                 public virtual object [] GetCustomAttributes (bool inherit)
80                 {
81                         return MonoCustomAttrs.GetCustomAttributes (this, inherit);
82                 }
83
84                 public virtual object [] GetCustomAttributes (Type attributeType, bool inherit)
85                 {
86                         return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
87                 }
88
89                 public virtual FileStream[] GetFiles ()
90                 {
91                         throw new NotImplementedException ();
92                 }
93
94                 public virtual FileStream GetFile (String name)
95                 {
96                         throw new NotImplementedException ();
97                 }
98
99                 public virtual Stream GetManifestResourceStream (String name)
100                 {
101                         throw new NotImplementedException ();
102                 }
103
104                 public virtual Stream GetManifestResourceStream (Type type, String name)
105                 {
106                         throw new NotImplementedException ();
107                 }
108
109                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
110                 private extern Type[] GetTypes (bool exportedOnly);
111                 
112                 public virtual Type[] GetTypes ()
113                 {
114                         return GetTypes (false);
115                 }
116
117                 public virtual Type[] GetExportedTypes ()
118                 {
119                         return GetTypes (true);
120                 }
121
122                 public virtual Type GetType (String name, Boolean throwOnError)
123                 {
124                         return GetType (name, throwOnError, false);
125                 }
126
127                 public virtual Type GetType (String name) {
128                         return GetType (name, false, false);
129                 }
130
131                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
132                 public extern Type GetType (String name, Boolean throwOnError, Boolean ignoreCase);
133                 
134                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
135                 static extern void FillName (Assembly ass, AssemblyName aname);
136                 
137                 public virtual AssemblyName GetName (Boolean copiedName)
138                 {
139                         AssemblyName aname = new AssemblyName ();
140                         FillName (this, aname);
141                         return aname;
142                 }
143
144                 public virtual AssemblyName GetName ()
145                 {
146                         return GetName (false);
147                 }
148
149                 public override String ToString ()
150                 {
151                         return GetName ().Name;
152                 }
153
154                 [MonoTODO]
155                 public static String CreateQualifiedName (String assemblyName, String typeName) 
156                 {
157                         return typeName + "," + assemblyName;
158                 }
159
160                 public static Assembly GetAssembly (Type type)
161                 {
162                         if (type != null)
163                                 return type.Assembly;
164                         throw new ArgumentNullException ("type");
165                 }
166
167                 [MonoTODO]
168                 public Assembly GetSatelliteAssembly (CultureInfo culture)
169                 {
170                         throw new NotImplementedException ();
171                 }
172
173                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
174                 public extern static Assembly LoadFrom (String assemblyFile);
175
176                 public static Assembly Load (String assemblyString)
177                 {
178                         return AppDomain.CurrentDomain.Load (assemblyString);
179                 }
180                 
181                 public static Assembly Load (String assemblyString, Evidence assemblySecurity)
182                 {
183                         return AppDomain.CurrentDomain.Load (assemblyString, assemblySecurity);
184                 }
185
186                 public static Assembly Load (AssemblyName assemblyRef)
187                 {
188                         return AppDomain.CurrentDomain.Load (assemblyRef);
189                 }
190
191                 public static Assembly Load (AssemblyName assemblyRef, Evidence assemblySecurity)
192                 {
193                         return AppDomain.CurrentDomain.Load (assemblyRef, assemblySecurity);
194                 }
195
196                 public static Assembly Load (Byte[] rawAssembly)
197                 {
198                         return AppDomain.CurrentDomain.Load (rawAssembly);
199                 }
200
201                 public static Assembly Load (Byte[] rawAssembly, Byte[] rawSymbolStore)
202                 {
203                         return AppDomain.CurrentDomain.Load (rawAssembly, rawSymbolStore);
204                 }
205
206                 public static Assembly Load (Byte[] rawAssembly, Byte[] rawSymbolStore,
207                                              Evidence securityEvidence)
208                 {
209                         return AppDomain.CurrentDomain.Load (rawAssembly, rawSymbolStore, securityEvidence);
210                 }
211
212                 public static Assembly LoadWithPartialName (string partialName)
213                 {
214                         return LoadWithPartialName (partialName, null);
215                 }
216
217                 [MonoTODO]
218                 public static Assembly LoadWithPartialName (string partialName, Evidence securityEvidence)
219                 {
220                         return AppDomain.CurrentDomain.Load (partialName, securityEvidence);
221                 }
222
223
224                 public Object CreateInstance (String typeName) 
225                 {
226                         return CreateInstance (typeName, false);
227                 }
228
229                 public Object CreateInstance (String typeName, Boolean ignoreCase)
230                 {
231                         Type t = GetType (typeName, true, ignoreCase);
232                         return Activator.CreateInstance (t);
233                 }
234
235                 public Object CreateInstance (String typeName, Boolean ignoreCase,
236                                               BindingFlags bindingAttr, Binder binder,
237                                               Object[] args, CultureInfo culture,
238                                               Object[] activationAttributes)
239                 {
240                         Type t = GetType (typeName, true, ignoreCase);
241                         return Activator.CreateInstance (t, bindingAttr, binder, args, culture, activationAttributes);
242                 }
243
244                 public Module[] GetLoadedModules ()
245                 {
246                         throw new NotImplementedException ();
247                 }
248
249                 public Module[] GetModules ()
250                 {
251                         throw new NotImplementedException ();
252                 }
253
254                 public Module GetModule (String name)
255                 {
256                         throw new NotImplementedException ();
257                 }
258
259                 public virtual String[] GetManifestResourceNames ()
260                 {
261                         throw new NotImplementedException ();
262                 }
263
264                 public static Assembly GetExecutingAssembly ()
265                 {
266                         throw new NotImplementedException ();
267                 }
268
269                 public AssemblyName[] GetReferencedAssemblies ()
270                 {
271                         throw new NotImplementedException ();
272                 }
273
274                 public virtual ManifestResourceInfo GetManifestResourceInfo (String resourceName)
275                 {
276                         throw new NotImplementedException ();
277                 }
278         }
279 }