2 // System.AppDomainSetup.cs
5 // Dietmar Maurer (dietmar@ximian.com)
6 // Sebastien Pouliot <sebastien@ximian.com>
8 // (C) 2001 Ximian, Inc. http://www.ximian.com
9 // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System.Runtime.CompilerServices;
33 using System.Runtime.InteropServices;
36 using System.Runtime.Hosting;
42 [ClassInterface (ClassInterfaceType.None)]
43 [MonoTODO ("Fix serialization compatibility with MS.NET")]
47 public sealed class AppDomainSetup : IAppDomainSetup
49 string application_base;
50 string application_name;
52 string configuration_file;
55 string private_bin_path;
56 string private_bin_path_probe;
57 string shadow_copy_directories;
58 string shadow_copy_files;
59 bool publisher_policy;
60 private bool path_changed;
61 private LoaderOptimization loader_optimization;
62 bool disallow_binding_redirects;
63 bool disallow_code_downloads;
65 private ActivationArguments _activationArguments;
68 public AppDomainSetup ()
72 internal AppDomainSetup (AppDomainSetup setup)
74 application_base = setup.application_base;
75 application_name = setup.application_name;
76 cache_path = setup.cache_path;
77 configuration_file = setup.configuration_file;
78 dynamic_base = setup.dynamic_base;
79 license_file = setup.license_file;
80 private_bin_path = setup.private_bin_path;
81 private_bin_path_probe = setup.private_bin_path_probe;
82 shadow_copy_directories = setup.shadow_copy_directories;
83 shadow_copy_files = setup.shadow_copy_files;
84 publisher_policy = setup.publisher_policy;
85 path_changed = setup.path_changed;
86 loader_optimization = setup.loader_optimization;
87 disallow_binding_redirects = setup.disallow_binding_redirects;
88 disallow_code_downloads = setup.disallow_code_downloads;
92 public AppDomainSetup (ActivationArguments activationArguments)
94 _activationArguments = activationArguments;
97 public AppDomainSetup (ActivationContext activationContext)
99 _activationArguments = new ActivationArguments (activationContext);
103 static string GetAppBase (string appBase)
108 int len = appBase.Length;
109 if (len >= 8 && appBase.ToLower ().StartsWith ("file://")) {
110 appBase = appBase.Substring (7);
111 if (Path.DirectorySeparatorChar != '/')
112 appBase = appBase.Replace ('/', Path.DirectorySeparatorChar);
113 if (Environment.IsRunningOnWindows) {
114 // Under Windows prepend "//" to indicate it's a local file
115 appBase = "//" + appBase;
120 // under 1.x the ":" gets a special treatment - but it doesn't make sense outside Windows
121 } else if (!Environment.IsRunningOnWindows || (appBase.IndexOf (':') == -1)) {
123 appBase = Path.GetFullPath (appBase);
129 public string ApplicationBase {
130 get { return GetAppBase (application_base); }
131 set { application_base = value; }
134 public string ApplicationName {
136 return application_name;
139 application_name = value;
143 public string CachePath {
152 public string ConfigurationFile {
154 return configuration_file;
157 configuration_file = value;
161 public bool DisallowPublisherPolicy {
163 return publisher_policy;
166 publisher_policy = value;
170 public string DynamicBase {
172 if (dynamic_base == null)
175 if (Path.IsPathRooted (dynamic_base))
178 if (ApplicationBase == null)
179 throw new MemberAccessException ("The ApplicationBase must be set before retrieving this property.");
181 return Path.Combine (ApplicationBase, dynamic_base);
184 if (application_name == null)
185 throw new MemberAccessException ("ApplicationName must be set before the DynamicBase can be set.");
186 uint id = (uint) application_name.GetHashCode ();
187 dynamic_base = Path.Combine (value, id.ToString("x"));
191 public string LicenseFile {
196 license_file = value;
200 [MonoTODO ("--share-code")]
201 public LoaderOptimization LoaderOptimization {
203 return loader_optimization;
206 loader_optimization = value;
210 public string PrivateBinPath {
212 return private_bin_path;
215 private_bin_path = value;
220 public string PrivateBinPathProbe {
222 return private_bin_path_probe;
225 private_bin_path_probe = value;
230 public string ShadowCopyDirectories {
232 return shadow_copy_directories;
235 shadow_copy_directories = value;
239 public string ShadowCopyFiles {
241 return shadow_copy_files;
244 shadow_copy_files = value;
249 public bool DisallowBindingRedirects {
251 return disallow_binding_redirects;
254 disallow_binding_redirects = value;
258 public bool DisallowCodeDownload {
260 return disallow_code_downloads;
263 disallow_code_downloads = value;
269 public ActivationArguments ActivationArguments {
270 get { return _activationArguments; }
271 set { _activationArguments = value; }