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)
//
// 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
{
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;
+ }
+
}
}
--- /dev/null
+
+//
+// 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;
+ }
+ }
+
+ }
+}
+
//
-// 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; }
}
}