2 // System.AppDomainSetup.cs
5 // Dietmar Maurer (dietmar@ximian.com)
7 // (C) 2001 Ximian, Inc. http://www.ximian.com
8 // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System.Runtime.CompilerServices;
32 using System.Runtime.InteropServices;
35 using System.Runtime.Hosting;
41 [ClassInterface (ClassInterfaceType.None)]
42 [MonoTODO ("Fix serialization compatibility with MS.NET")]
43 public sealed class AppDomainSetup : IAppDomainSetup
45 string application_base;
46 string application_name;
48 string configuration_file;
51 string private_bin_path;
52 string private_bin_path_probe;
53 string shadow_copy_directories;
54 string shadow_copy_files;
55 bool publisher_policy;
56 private bool path_changed;
57 private LoaderOptimization loader_optimization;
58 bool disallow_binding_redirects;
59 bool disallow_code_downloads;
61 private ActivationArguments _activationArguments;
64 public AppDomainSetup ()
68 internal AppDomainSetup (AppDomainSetup setup)
70 application_base = setup.application_base;
71 application_name = setup.application_name;
72 cache_path = setup.cache_path;
73 configuration_file = setup.configuration_file;
74 dynamic_base = setup.dynamic_base;
75 license_file = setup.license_file;
76 private_bin_path = setup.private_bin_path;
77 private_bin_path_probe = setup.private_bin_path_probe;
78 shadow_copy_directories = setup.shadow_copy_directories;
79 shadow_copy_files = setup.shadow_copy_files;
80 publisher_policy = setup.publisher_policy;
81 path_changed = setup.path_changed;
82 loader_optimization = setup.loader_optimization;
83 disallow_binding_redirects = setup.disallow_binding_redirects;
84 disallow_code_downloads = setup.disallow_code_downloads;
88 public AppDomainSetup (ActivationArguments activationArguments)
90 _activationArguments = activationArguments;
93 [MonoTODO ("LAMESPEC")]
94 public AppDomainSetup (ActivationContext activationContext)
96 if (activationContext == null)
97 throw new ArgumentNullException ("activationContext");
99 // _activationArguments = activationContext.ActivationArguments;
101 // LAMESPEC: beta2 docs says that the context supplies a
102 // ActivationArguments object which isn't the case!
106 static string GetAppBase (string appBase)
108 if (appBase == null) return null;
109 int len = appBase.Length;
110 if (len >= 8 && appBase.ToLower ().StartsWith ("file://")) {
111 appBase = appBase.Substring (7);
112 if (Path.DirectorySeparatorChar != '/')
113 appBase = appBase.Replace ('/', Path.DirectorySeparatorChar);
115 } else if (appBase.IndexOf (':') == -1) {
116 appBase = Path.GetFullPath (appBase);
122 public string ApplicationBase {
124 return application_base;
127 application_base = GetAppBase (value);
131 public string ApplicationName {
133 return application_name;
136 application_name = value;
140 public string CachePath {
149 public string ConfigurationFile {
151 return configuration_file;
154 configuration_file = value;
158 public bool DisallowPublisherPolicy {
160 return publisher_policy;
163 publisher_policy = value;
167 public string DynamicBase {
169 if (dynamic_base == null)
172 if (Path.IsPathRooted (dynamic_base))
175 if (ApplicationBase == null)
176 throw new MemberAccessException ("The ApplicationBase must be set before retrieving this property.");
178 return Path.Combine (ApplicationBase, dynamic_base);
181 if (application_name == null)
182 throw new MemberAccessException ("ApplicationName must be set before the DynamicBase can be set.");
183 uint id = (uint) application_name.GetHashCode ();
184 dynamic_base = Path.Combine (value, id.ToString("x"));
188 public string LicenseFile {
193 license_file = value;
197 [MonoTODO ("--share-code")]
198 public LoaderOptimization LoaderOptimization {
200 return loader_optimization;
203 loader_optimization = value;
207 public string PrivateBinPath {
209 return private_bin_path;
212 private_bin_path = value;
217 public string PrivateBinPathProbe {
219 return private_bin_path_probe;
222 private_bin_path_probe = value;
227 public string ShadowCopyDirectories {
229 return shadow_copy_directories;
232 shadow_copy_directories = value;
236 public string ShadowCopyFiles {
238 return shadow_copy_files;
241 shadow_copy_files = value;
246 public bool DisallowBindingRedirects {
248 return disallow_binding_redirects;
251 disallow_binding_redirects = value;
255 public bool DisallowCodeDownload {
257 return disallow_code_downloads;
260 disallow_code_downloads = value;
266 public ActivationArguments ActivationArguments {
267 get { return _activationArguments; }
268 set { _activationArguments = value; }