added some AppDomain methods
authorDietmar Maurer <dietmar@mono-cvs.ximian.com>
Wed, 23 Jan 2002 09:49:10 +0000 (09:49 -0000)
committerDietmar Maurer <dietmar@mono-cvs.ximian.com>
Wed, 23 Jan 2002 09:49:10 +0000 (09:49 -0000)
svn path=/trunk/mcs/; revision=2122

mcs/class/corlib/System.Reflection/Assembly.cs
mcs/class/corlib/System.Reflection/AssemblyName.cs
mcs/class/corlib/System/AppDomain.cs
mcs/class/corlib/System/AppDomainSetup.cs [new file with mode: 0755]
mcs/class/corlib/System/IAppDomainSetup.cs

index 17615f0744d85fae63bd9273dc8fb31b6d7e30cb..8514a02235f91815ba850b9345b9173a1e9d5951 100644 (file)
@@ -184,45 +184,42 @@ namespace System.Reflection {
 
                public static Assembly LoadFrom(String assemblyFile)
                {
-                       return LoadFrom (assemblyFile, new Evidence());
+                       return AppDomain.CurrentDomain.Load (assemblyFile);
                }
 
-               [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               public static extern Assembly LoadFrom(String assemblyFile, Evidence securityEvidence);
-
                public static Assembly Load(String assemblyString)
                {
-                       return LoadFrom (assemblyString, new Evidence());
+                       return AppDomain.CurrentDomain.Load (assemblyString);
                }
                
                public static Assembly Load(String assemblyString, Evidence assemblySecurity)
                {
-                       return LoadFrom (assemblyString, assemblySecurity);
+                       return AppDomain.CurrentDomain.Load (assemblyString, assemblySecurity);
                }
 
                public static Assembly Load(AssemblyName assemblyRef)
                {
-                       throw new NotImplementedException ();
+                       return AppDomain.CurrentDomain.Load (assemblyRef);
                }
 
                public static Assembly Load(AssemblyName assemblyRef, Evidence assemblySecurity)
                {
-                       throw new NotImplementedException ();
+                       return AppDomain.CurrentDomain.Load (assemblyRef, assemblySecurity);
                }
 
                public static Assembly Load(Byte[] rawAssembly)
                {
-                       throw new NotImplementedException ();
+                       return AppDomain.CurrentDomain.Load (rawAssembly);
                }
 
                public static Assembly Load(Byte[] rawAssembly, Byte[] rawSymbolStore)
                {
-                       throw new NotImplementedException ();
+                       return AppDomain.CurrentDomain.Load (rawAssembly, rawSymbolStore);
                }
 
                public static Assembly Load(Byte[] rawAssembly, Byte[] rawSymbolStore, Evidence securityEvidence)
                {
-                       throw new NotImplementedException ();
+                       return AppDomain.CurrentDomain.Load (rawAssembly, rawSymbolStore, securityEvidence);
                }
 
                public Object CreateInstance(String typeName) 
index 3599b19fb3b6cfff88d16b93e331085fb01f1ac0..da8a10d1917635e1581ab9f3bbd5a0b208587538 100755 (executable)
@@ -11,7 +11,9 @@ using System;
 using System.Reflection;
 
 namespace System.Reflection {
+
        public class AssemblyName /* : ICloneable, ISerializable, IDeserializationCallback */ {
+
                private string name;
                
                public virtual string Name {
@@ -23,6 +25,24 @@ namespace System.Reflection {
                        name = null;
                }
 
+               public override int GetHashCode ()
+               {
+                       return name.GetHashCode ();
+               }
+
+               public override bool Equals (object o)
+               {
+                       if (!(o is System.Reflection.AssemblyName))
+                               return false;
+
+                       AssemblyName an = (AssemblyName)o;
+
+                       if (an.name == this.name)
+                               return true;
+                       
+                       return false;
+               }
+
        }
 
 }
index b766b6357584bc897df025ca7b532a6f7bca9172..0447910b92464b86493abaf96f5405929c086376 100755 (executable)
 //
 // System/AppDomain.cs
 //
-// Author:
+// Authors:
 //   Paolo Molaro (lupus@ximian.com)
+//   Dietmar Maurer (dietmar@ximian.com)
 //
 // (C) 2001 Ximian, Inc.  http://www.ximian.com
 //
 
 using System;
+using System.Collections;
 using System.Reflection;
 using System.Reflection.Emit;
 using System.Runtime.CompilerServices;
+using System.Security.Policy;
 
 namespace System {
 
-       public interface AppDomain_Intf {
-       }
-
        public sealed class AppDomain /* : MarshalByRefObject , _AppDomain, IEvidenceFactory */ {
 
-               [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               private static extern AppDomain getCurDomain ();
+               private Hashtable loaded_assemblies = new Hashtable ();
+
+               private Hashtable data_hash = new Hashtable ();
+               
+               private AppDomainSetup adsetup;
+
+               private string friendly_name;
+
+               private Evidence evidence;
+
+               public AppDomainSetup SetupInformation {
+
+                       get {
+                               return adsetup;
+                       }
+               }
+
+               public string BaseDirectory {
+
+                       get {
+                               return adsetup.ApplicationBase;
+                       }
+               }
+
+               public string RelativeSearchPath {
+
+                       get {
+                               return adsetup.PrivateBinPath;
+                       }
+               }
+
+               public string DynamicDirectory {
+
+                       get {
+                               // fixme: dont know what to return here
+                               return null;
+                       }
+               }
+
+               public string FriendlyName {
+
+                       get {
+                               return friendly_name;
+                       }
+               }
+
+               public Evidence Evidence {
+
+                       get {
+                               return evidence;
+                       }
+               }
+
+               
+               public static AppDomain CreateDomain(string friendlyName)
+               {
+                       return CreateDomain (friendlyName, new Evidence (), new AppDomainSetup ());
+               }
                
+               public static AppDomain CreateDomain(string friendlyName, Evidence securityInfo)
+               {
+                       return CreateDomain (friendlyName, securityInfo, new AppDomainSetup ());
+               }
+               
+               public static AppDomain CreateDomain(string friendlyName, Evidence securityInfo, AppDomainSetup info)
+               {
+                       if (friendlyName == null || securityInfo == null || info == null)
+                               throw new System.ArgumentNullException();
+
+                       AppDomain ad = new AppDomain ();
+
+                       ad.friendly_name = friendlyName;
+                       ad.evidence = securityInfo;
+                       ad.adsetup = info;
+                       
+                       return ad;
+               }
+
+               public static AppDomain CreateDomain(string friendlyName, Evidence securityInfo, string appBasePath,
+                                                    string appRelativeSearchPath, bool shadowCopyFiles)
+               {
+                       AppDomainSetup info = new AppDomainSetup ();
+
+                       info.ApplicationBase = appBasePath;
+                       info.PrivateBinPath = appRelativeSearchPath;
+
+                       if (shadowCopyFiles)
+                               info.ShadowCopyFiles = "true";
+                       else
+                               info.ShadowCopyFiles = "false";
+
+                       return CreateDomain (friendlyName, securityInfo, info);
+               }
+               
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               public static extern Assembly LoadFrom(String assemblyFile, Evidence securityEvidence);
+
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               private static extern Assembly [] getAssemblies ();
+               private static extern AppDomain getCurDomain ();
                
                public static AppDomain CurrentDomain
                {
@@ -40,9 +134,99 @@ namespace System {
                        return ab;
                }
 
-               public Assembly [] GetAssemblies ()
+               public Assembly Load (AssemblyName assemblyRef)
+               {
+                       return Load (assemblyRef, new Evidence ());
+               }
+
+               public Assembly Load (AssemblyName assemblyRef, Evidence assemblySecurity)
+               {
+                       Assembly res;
+                       
+                       if ((res = (Assembly)loaded_assemblies [assemblyRef]) != null)
+                               return res;
+
+                       // fixme: we should pass the whole assemblyRef instead of the name,
+                       // and maybe also the adsetup
+                       res = LoadFrom (assemblyRef.Name, assemblySecurity);
+
+                       loaded_assemblies [assemblyRef] = res;
+                       
+                       return res;
+               }
+
+               public Assembly Load (string assemblyString)
+               {
+                       AssemblyName an = new AssemblyName ();
+                       an.Name = assemblyString;
+                       
+                       return Load (an, new Evidence ());                      
+               }
+
+               public Assembly Load (string assemblyString, Evidence assemblySecurity)
                {
-                       return getAssemblies ();
+                       AssemblyName an = new AssemblyName ();
+                       an.Name = assemblyString;
+                       
+                       return Load (an, assemblySecurity);                     
                }
+
+               public Assembly Load (byte[] rawAssembly)
+               {
+                       return Load (rawAssembly, null, new Evidence ());
+               }
+
+               public Assembly Load (byte[] rawAssembly, byte[] rawSymbolStore)
+               {
+                       return Load (rawAssembly, rawSymbolStore, new Evidence ());
+               }
+
+               public Assembly Load (byte[] rawAssembly, byte[] rawSymbolStore, Evidence securityEvidence)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public Assembly[] GetAssemblies ()
+               {
+                       int x = loaded_assemblies.Count;
+                       return null;
+                       Assembly[] res = new Assembly [loaded_assemblies.Count];
+
+                       IDictionaryEnumerator it = loaded_assemblies.GetEnumerator ();
+                       int i = 0;
+
+                       
+                       while (it.MoveNext ())
+                               res [i++] = (Assembly)it.Value;
+
+                       return res;
+               }
+
+               // fixme: how does marshalling work ?
+               public object GetData (string name)
+               {
+                       switch (name) {
+                       case "APPBASE": return adsetup.ApplicationBase;
+                       case "APP_CONFIG_FILE": return adsetup.ConfigurationFile;
+                       case "DYNAMIC_BASE": return adsetup.DynamicBase;
+                       case "APP_NAME": return adsetup.ApplicationName;
+                       case "CACHE_BASE": return adsetup.CachePath;
+                       case "PRIVATE_BINPATH": return adsetup.PrivateBinPath;
+                       case "BINPATH_PROBE_ONLY": return adsetup.PrivateBinPathProbe;
+                       case "SHADOW_COPY_DIRS": return adsetup.ShadowCopyDirectories;
+                       case "FORCE_CACHE_INSTALL": return adsetup.ShadowCopyFiles;
+                       }
+
+                       return data_hash [name];
+               }
+
+               // fixme: how does marshalling work ?
+               public void SetData (string name, object data)
+               {
+                       // LAMESPEC: why can't we set adsetup properties ??
+
+                       data_hash [name] = data;
+               }
+
        }
 }
diff --git a/mcs/class/corlib/System/AppDomainSetup.cs b/mcs/class/corlib/System/AppDomainSetup.cs
new file mode 100755 (executable)
index 0000000..7093c61
--- /dev/null
@@ -0,0 +1,149 @@
+
+//
+// System/AppDomainSetup.cs
+//
+// Author:
+//   Dietmar Maurer (dietmar@ximian.com)
+//
+// (C) 2001 Ximian, Inc.  http://www.ximian.com
+//
+
+using System;
+using System.Runtime.CompilerServices;
+
+namespace System {
+
+
+       public sealed class AppDomainSetup : IAppDomainSetup {
+
+               private string application_base;
+               private string application_name;
+               private string cache_path;
+               private string configuration_file;
+               private string dynamic_base;
+               private string license_file;
+               private string private_bin_path;
+               private string private_bin_path_probe;
+               private string shadow_copy_directories;
+               private string shadow_copy_files;
+
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               private static extern AppDomainSetup InitAppDomainSetup (AppDomainSetup setup);
+
+               public AppDomainSetup ()
+               {
+                       InitAppDomainSetup (this);
+               }
+               
+               public string ApplicationBase {
+
+                       get {
+                               return application_base;
+                       }
+
+                       set {
+                               application_base = value;
+                       }
+               }
+
+               public string ApplicationName {
+
+                       get {
+                               return application_name;
+                       }
+
+                       set {
+                               application_name = value;
+                       }
+               }
+
+               public string CachePath {
+
+                       get {
+                               return cache_path;
+                       }
+
+                       set {
+                               cache_path = value;
+                       }
+               }
+
+               public string ConfigurationFile {
+
+                       get {
+                               return configuration_file;
+                       }
+
+                       set {
+                               configuration_file = value;
+                       }
+               }
+
+               public string DynamicBase {
+
+                       get {
+                               return dynamic_base;
+                       }
+
+                       set {
+                               dynamic_base = value;
+                       }
+               }
+
+               public string LicenseFile {
+
+                       get {
+                               return license_file;
+                       }
+
+                       set {
+                               license_file = value;
+                       }
+               }
+
+               public string PrivateBinPath {
+
+                       get {
+                               return private_bin_path;
+                       }
+
+                       set {
+                               private_bin_path = value;
+                       }
+               }
+
+               public string PrivateBinPathProbe {
+
+                       get {
+                               return private_bin_path_probe;
+                       }
+
+                       set {
+                               private_bin_path_probe = value;
+                       }
+               }
+
+               public string ShadowCopyDirectories {
+
+                       get {
+                               return shadow_copy_directories;
+                       }
+
+                       set {
+                               shadow_copy_directories = value;
+                       }
+               }
+
+               public string ShadowCopyFiles {
+
+                       get {
+                               return shadow_copy_files;
+                       }
+
+                       set {
+                               shadow_copy_files = value;
+                       }
+               }
+               
+       }
+}
index 4a54c6040ea8666744aeb7b760669dedf003dd13..31eddcd62b774783dbb43eb63f30027f4a06a499 100644 (file)
@@ -1,26 +1,37 @@
+
 //
-// System.IAppDomainSetup
+// System/IAppDomainSetup.cs
 //
 // Author:
-//   Duco Fijma (duco@lorentz.xs4all.nl)
+//   Dietmar Maurer (dietmar@ximian.com)
 //
-// (C) 2002, Duco Fijma
+// (C) 2001 Ximian, Inc.  http://www.ximian.com
 //
 
+using System;
+
 namespace System {
 
        public interface IAppDomainSetup {
 
-               string ApplicationBase {get; }
-               string ApplicationName {get; }
-               string CachePath {get; }
-               string ConfigurationFile {get; }
-               string DynamicBase {get; }
-               string LicenseFile {get; }
-               string PrivateBinPath {get; }
-               string PrivateBinPathProbe {get; }
-               string ShadowCopyDirectories {get; }
-               string ShadowCopyFiles {get; }
+               string ApplicationBase { get; set; }
+
+               string ApplicationName { get; set; }
+
+               string CachePath { get; set; }
+
+               string ConfigurationFile { get; set; }
+
+               string DynamicBase { get; set; }
+
+               string LicenseFile { get; set; }
+
+               string PrivateBinPath { get; set; }
+
+               string PrivateBinPathProbe { get; set; }
+
+               string ShadowCopyDirectories { get; set; }
 
+               string ShadowCopyFiles { get; set; }
        }
 }