Mon Jul 1 18:01:49 CEST 2002 Paolo Molaro <lupus@ximian.com>
[mono.git] / mcs / class / corlib / System.Reflection / Assembly.cs
index 88c89dad0a8172227cb98facee82dadd16fce38d..62c1011e0c8c15510f079aec68293be0b7e0136c 100644 (file)
@@ -17,10 +17,13 @@ using System.Runtime.CompilerServices;
 
 namespace System.Reflection {
 
+       [Serializable]
        public class Assembly : System.Reflection.ICustomAttributeProvider,
                System.Security.IEvidenceFactory, System.Runtime.Serialization.ISerializable {
                private IntPtr _mono_assembly;
 
+               internal Assembly () {}
+
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                private extern string get_code_base ();
                
@@ -30,7 +33,7 @@ namespace System.Reflection {
                        }
                }
 
-               public virtual string CopiedCodeBase {
+               internal virtual string CopiedCodeBase {
                        get {
                                return null;
                        }
@@ -83,36 +86,6 @@ namespace System.Reflection {
                        return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
                }
 
-               public virtual void RemoveOnTypeResolve (ResolveEventHandler handler)
-               {
-                       throw new NotImplementedException ();
-               }
-
-               public virtual void AddOnTypeResolve (ResolveEventHandler handler)
-               {
-                       throw new NotImplementedException ();
-               }
-
-               public virtual void RemoveOnResourceResolve (ResolveEventHandler handler)
-               {
-                       throw new NotImplementedException ();
-               }
-               
-               public virtual void AddOnResourceResolve (ResolveEventHandler handler)
-               {
-                       throw new NotImplementedException ();
-               }
-
-               public virtual ModuleBuilder DefineDynamicModule (String name, Boolean emitSymbolInfo)
-               {
-                       throw new NotImplementedException ();
-               }
-
-               public virtual ModuleBuilder DefineDynamicModule (String name)
-               {
-                       throw new NotImplementedException ();
-               }
-
                public virtual FileStream[] GetFiles ()
                {
                        throw new NotImplementedException ();
@@ -133,14 +106,17 @@ namespace System.Reflection {
                        throw new NotImplementedException ();
                }
 
+               [MethodImplAttribute (MethodImplOptions.InternalCall)]
+               private extern Type[] GetTypes (bool exportedOnly);
+               
                public virtual Type[] GetTypes ()
                {
-                       throw new NotImplementedException ();
+                       return GetTypes (false);
                }
 
                public virtual Type[] GetExportedTypes ()
                {
-                       throw new NotImplementedException ();
+                       return GetTypes (true);
                }
 
                public virtual Type GetType (String name, Boolean throwOnError)
@@ -155,14 +131,19 @@ namespace System.Reflection {
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                public extern Type GetType (String name, Boolean throwOnError, Boolean ignoreCase);
                
+               [MethodImplAttribute (MethodImplOptions.InternalCall)]
+               static extern void FillName (Assembly ass, AssemblyName aname);
+               
                public virtual AssemblyName GetName (Boolean copiedName)
                {
-                       throw new NotImplementedException ();
+                       AssemblyName aname = new AssemblyName ();
+                       FillName (this, aname);
+                       return aname;
                }
 
                public virtual AssemblyName GetName ()
                {
-                       throw new NotImplementedException ();
+                       return GetName (false);
                }
 
                public override String ToString ()
@@ -173,19 +154,14 @@ namespace System.Reflection {
                [MonoTODO]
                public static String CreateQualifiedName (String assemblyName, String typeName) 
                {
-                       return "FIXME: assembly";
-               }
-
-               [MonoTODO]
-               public static String nCreateQualifiedName (String assemblyName, String typeName)
-               {
-                       return "FIXME: assembly";
+                       return typeName + "," + assemblyName;
                }
 
-               [MonoTODO]
                public static Assembly GetAssembly (Type type)
                {
-                       throw new NotImplementedException ();
+                       if (type != null)
+                               return type.Assembly;
+                       throw new ArgumentNullException ("type");
                }
 
                [MonoTODO]
@@ -194,10 +170,8 @@ namespace System.Reflection {
                        throw new NotImplementedException ();
                }
 
-               public static Assembly LoadFrom (String assemblyFile)
-               {
-                       return AppDomain.CurrentDomain.Load (assemblyFile);
-               }
+               [MethodImplAttribute (MethodImplOptions.InternalCall)]
+               public extern static Assembly LoadFrom (String assemblyFile);
 
                public static Assembly Load (String assemblyString)
                {
@@ -235,14 +209,27 @@ namespace System.Reflection {
                        return AppDomain.CurrentDomain.Load (rawAssembly, rawSymbolStore, securityEvidence);
                }
 
+               public static Assembly LoadWithPartialName (string partialName)
+               {
+                       return LoadWithPartialName (partialName, null);
+               }
+
+               [MonoTODO]
+               public static Assembly LoadWithPartialName (string partialName, Evidence securityEvidence)
+               {
+                       return AppDomain.CurrentDomain.Load (partialName, securityEvidence);
+               }
+
+
                public Object CreateInstance (String typeName) 
                {
-                       throw new NotImplementedException ();
+                       return CreateInstance (typeName, false);
                }
 
                public Object CreateInstance (String typeName, Boolean ignoreCase)
                {
-                       throw new NotImplementedException ();
+                       Type t = GetType (typeName, true, ignoreCase);
+                       return Activator.CreateInstance (t);
                }
 
                public Object CreateInstance (String typeName, Boolean ignoreCase,
@@ -250,7 +237,8 @@ namespace System.Reflection {
                                              Object[] args, CultureInfo culture,
                                              Object[] activationAttributes)
                {
-                       throw new NotImplementedException ();
+                       Type t = GetType (typeName, true, ignoreCase);
+                       return Activator.CreateInstance (t, bindingAttr, binder, args, culture, activationAttributes);
                }
 
                public Module[] GetLoadedModules ()
@@ -268,7 +256,7 @@ namespace System.Reflection {
                        throw new NotImplementedException ();
                }
 
-               public String[] GetManifestResourceNames ()
+               public virtual String[] GetManifestResourceNames ()
                {
                        throw new NotImplementedException ();
                }
@@ -283,22 +271,9 @@ namespace System.Reflection {
                        throw new NotImplementedException ();
                }
 
-               public ManifestResourceInfo GetManifestResourceInfo (String resourceName)
+               public virtual ManifestResourceInfo GetManifestResourceInfo (String resourceName)
                {
                        throw new NotImplementedException ();
                }
-
-               public static Assembly Load (AssemblyName assemblyRef, Evidence assemblySecurity,
-                                            String callerLocation)
-               {
-                       throw new NotImplementedException ();
-               }
-
-               public static Assembly Load (String assemblyString, Evidence assemblySecurity,
-                                            String callerLocation)
-               {
-                       throw new NotImplementedException ();
-               }
-
        }
 }