//
// (C) 2001, 2002 Ximian, Inc. http://www.ximian.com
// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+// Copyright 2011 Xamarin Inc (http://www.xamarin.com).
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
namespace System {
[ComVisible (true)]
-#if !NET_2_1
+#if !NET_2_1 || MOONLIGHT
[ComDefaultInterface (typeof (_AppDomain))]
#endif
[ClassInterface(ClassInterfaceType.None)]
-#if NET_2_1
- public sealed class AppDomain : MarshalByRefObject {
+ [StructLayout (LayoutKind.Sequential)]
+#if MOONLIGHT
+ public sealed class AppDomain : _AppDomain {
+#elif NET_2_1
+ public sealed class AppDomain : MarshalByRefObject, _AppDomain {
#else
public sealed class AppDomain : MarshalByRefObject, _AppDomain, IEvidenceFactory {
#endif
[ThreadStatic]
static Hashtable assembly_resolve_in_progress_refonly;
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
// CAS
private Evidence _evidence;
private PermissionSet _granted;
get { throw new NotImplementedException (); }
}
#endif
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
public string BaseDirectory {
get {
string path = SetupInformationNoCopy.ApplicationBase;
+#if !NET_2_1
if (SecurityManager.SecurityEnabled && (path != null) && (path.Length > 0)) {
// we cannot divulge local file informations
new FileIOPermission (FileIOPermissionAccess.PathDiscovery, path).Demand ();
}
+#endif
return path;
}
}
public string RelativeSearchPath {
get {
string path = SetupInformationNoCopy.PrivateBinPath;
+#if !NET_2_1
if (SecurityManager.SecurityEnabled && (path != null) && (path.Length > 0)) {
// we cannot divulge local file informations
new FileIOPermission (FileIOPermissionAccess.PathDiscovery, path).Demand ();
}
+#endif
return path;
}
}
return null;
string path = Path.Combine (setup.DynamicBase, setup.ApplicationName);
+#if !NET_2_1
if (SecurityManager.SecurityEnabled && (path != null) && (path.Length > 0)) {
// we cannot divulge local file informations
new FileIOPermission (FileIOPermissionAccess.PathDiscovery, path).Demand ();
}
+#endif
return path;
}
}
return getFriendlyName ();
}
}
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
public Evidence Evidence {
get {
// if the host (runtime) hasn't provided it's own evidence...
get { return _granted; }
}
#endif
+
+#if NET_4_0
+ public PermissionSet PermissionSet {
+ get { return _granted ?? (_granted = new PermissionSet (PermissionState.Unrestricted)); }
+ }
+#endif
+
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private static extern AppDomain getCurDomain ();
}
}
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
[Obsolete ("AppDomain.AppendPrivatePath has been deprecated. Please investigate the use of AppDomainSetup.PrivateBinPath instead.")]
[SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
culture, activationAttributes, null);
}
- public object CreateInstanceFromAndUnwrap (string assemblyName, string typeName, bool ignoreCase,
+ public object CreateInstanceFromAndUnwrap (string assemblyFile, string typeName, bool ignoreCase,
BindingFlags bindingAttr, Binder binder, object[] args,
CultureInfo culture, object[] activationAttributes)
{
- ObjectHandle oh = CreateInstanceFrom (assemblyName, typeName, ignoreCase, bindingAttr, binder, args,
+ ObjectHandle oh = CreateInstanceFrom (assemblyFile, typeName, ignoreCase, bindingAttr, binder, args,
culture, activationAttributes);
return (oh != null) ? oh.Unwrap () : null;
}
// NET 3.5 method
- public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, IEnumerable<CustomAttributeBuilder> assemblyAttributes) {
+ public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, IEnumerable<CustomAttributeBuilder> assemblyAttributes)
+ {
return DefineDynamicAssembly (name, access, null, null, null, null, null, false, assemblyAttributes);
}
+#if NET_4_0
+ public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, string dir, bool isSynchronized, IEnumerable<CustomAttributeBuilder> assemblyAttributes)
+ {
+ return DefineDynamicAssembly (name, access, dir, null, null, null, null, isSynchronized, assemblyAttributes);
+ }
+
+ [MonoLimitation ("The argument securityContextSource is ignored")]
+ public AssemblyBuilder DefineDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access, IEnumerable<CustomAttributeBuilder> assemblyAttributes, SecurityContextSource securityContextSource)
+ {
+ return DefineDynamicAssembly (name, access, assemblyAttributes);
+ }
+#endif
+
internal AssemblyBuilder DefineInternalDynamicAssembly (AssemblyName name, AssemblyBuilderAccess access)
{
return new AssemblyBuilder (name, null, access, true);
return base.GetType ();
}
+#if !MOONLIGHT
public override object InitializeLifetimeService ()
{
return null;
}
+#endif
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal extern Assembly LoadAssembly (string assemblyRef, Evidence securityEvidence, bool refOnly);
if (assemblyRef.Name != aname.Name)
throw new FileNotFoundException (null, assemblyRef.Name);
- if (assemblyRef.Version != new Version () && assemblyRef.Version != aname.Version)
+ if (assemblyRef.Version != null && assemblyRef.Version != new Version (0, 0, 0, 0) && assemblyRef.Version != aname.Version)
throw new FileNotFoundException (null, assemblyRef.Name);
if (assemblyRef.CultureInfo != null && assemblyRef.CultureInfo.Equals (aname))
throw new FileNotFoundException (null, assemblyRef.Name);
byte [] pt = assemblyRef.GetPublicKeyToken ();
- if (pt != null) {
+ if (pt != null && pt.Length != 0) {
byte [] loaded_pt = aname.GetPublicKeyToken ();
if (loaded_pt == null || (pt.Length != loaded_pt.Length))
throw new FileNotFoundException (null, assemblyRef.Name);
assembly.FromByteArray = true;
return assembly;
}
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
#if NET_4_0
[Obsolete ("AppDomain policy levels are obsolete")]
#endif
return _process_guid;
}
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
public static AppDomain CreateDomain (string friendlyName)
{
public override string ToString ()
{
-#if !NET_2_1 || MONOTOUCH
+#if !MOONLIGHT
return getFriendlyName ();
#else
StringBuilder sb = new StringBuilder ("Name:");
}
}
+ internal Assembly DoResourceResolve (string name, Assembly requesting) {
+ if (ResourceResolve == null)
+ return null;
+
+ Delegate[] invocation_list = ResourceResolve.GetInvocationList ();
+
+ foreach (Delegate eh in invocation_list) {
+ ResolveEventHandler handler = (ResolveEventHandler) eh;
+#if NET_4_0
+ Assembly assembly = handler (this, new ResolveEventArgs (name, requesting));
+#else
+ Assembly assembly = handler (this, new ResolveEventArgs (name));
+#endif
+ if (assembly != null)
+ return assembly;
+ }
+ return null;
+ }
+
private void DoDomainUnload ()
{
if (DomainUnload != null)
DomainUnload(this, null);
}
-#if !NET_2_1
internal byte[] GetMarshalledDomainObjRef ()
{
ObjRef oref = RemotingServices.Marshal (AppDomain.CurrentDomain, null, typeof (AppDomain));
return CADSerializer.SerializeObject (oref).GetBuffer();
}
-#endif
+
internal void ProcessMessageInDomain (byte[] arrRequest, CADMethodCallMessage cadMsg,
out byte[] arrResponse, out CADMethodReturnMessage cadMrm)
{
[method: SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
public event UnhandledExceptionEventHandler UnhandledException;
-#if NET_4_0 || BOOTSTRAP_NET_4_0
+#if NET_4_0
[MonoTODO]
public bool IsHomogenous {
get { return true; }
}
+
+ [MonoTODO]
+ public bool IsFullyTrusted {
+ get { return true; }
+ }
#endif
#pragma warning disable 649
get { return _domain_manager; }
}
-#if (!NET_2_1 || MONOTOUCH)
+#if (!MOONLIGHT)
public event ResolveEventHandler ReflectionOnlyAssemblyResolve;
{
return GetAssemblies (true);
}
-#endif
-#if NET_2_1 && !MONOTOUCH
+#else // MOONLIGHT
+
public int ExecuteAssemblyByName (string assemblyName)
{
// critical code in SL that we're not calling in ML
throw new NotImplementedException ();
}
#endif
+
+#if NET_4_0 || MOONLIGHT || MOBILE
+ List<string> compatibility_switch;
+
+ public bool? IsCompatibilitySwitchSet (string value)
+ {
+ if (value == null)
+ throw new ArgumentNullException ("value");
+
+ // default (at least for SL4) is to return false for unknown values (can't get a null out of it)
+ return ((compatibility_switch != null) && compatibility_switch.Contains (value));
+ }
+
+ internal void SetCompatibilitySwitch (string value)
+ {
+ if (compatibility_switch == null)
+ compatibility_switch = new List<string> ();
+ compatibility_switch.Add (value);
+ }
+
+ [MonoTODO ("Currently always returns false")]
+ public static bool MonitoringIsEnabled {
+ get { return false; }
+ set { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public long MonitoringSurvivedMemorySize {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public static long MonitoringSurvivedProcessMemorySize {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public long MonitoringTotalAllocatedMemorySize {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ public TimeSpan MonitoringTotalProcessorTime {
+ get { throw new NotImplementedException (); }
+ }
+#endif
}
}