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)
12 // Fix serialization compatibility with MS.NET.
14 // Permission is hereby granted, free of charge, to any person obtaining
15 // a copy of this software and associated documentation files (the
16 // "Software"), to deal in the Software without restriction, including
17 // without limitation the rights to use, copy, modify, merge, publish,
18 // distribute, sublicense, and/or sell copies of the Software, and to
19 // permit persons to whom the Software is furnished to do so, subject to
20 // the following conditions:
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 using System.Runtime.CompilerServices;
36 using System.Runtime.InteropServices;
39 using System.Runtime.Hosting;
45 [ClassInterface (ClassInterfaceType.None)]
49 public sealed class AppDomainSetup : IAppDomainSetup
51 string application_base;
52 string application_name;
54 string configuration_file;
57 string private_bin_path;
58 string private_bin_path_probe;
59 string shadow_copy_directories;
60 string shadow_copy_files;
61 bool publisher_policy;
62 private bool path_changed;
63 private LoaderOptimization loader_optimization;
64 bool disallow_binding_redirects;
65 bool disallow_code_downloads;
67 private ActivationArguments _activationArguments;
70 public AppDomainSetup ()
74 internal AppDomainSetup (AppDomainSetup setup)
76 application_base = setup.application_base;
77 application_name = setup.application_name;
78 cache_path = setup.cache_path;
79 configuration_file = setup.configuration_file;
80 dynamic_base = setup.dynamic_base;
81 license_file = setup.license_file;
82 private_bin_path = setup.private_bin_path;
83 private_bin_path_probe = setup.private_bin_path_probe;
84 shadow_copy_directories = setup.shadow_copy_directories;
85 shadow_copy_files = setup.shadow_copy_files;
86 publisher_policy = setup.publisher_policy;
87 path_changed = setup.path_changed;
88 loader_optimization = setup.loader_optimization;
89 disallow_binding_redirects = setup.disallow_binding_redirects;
90 disallow_code_downloads = setup.disallow_code_downloads;
94 public AppDomainSetup (ActivationArguments activationArguments)
96 _activationArguments = activationArguments;
99 public AppDomainSetup (ActivationContext activationContext)
101 _activationArguments = new ActivationArguments (activationContext);
105 static string GetAppBase (string appBase)
110 int len = appBase.Length;
111 if (len >= 8 && appBase.ToLower ().StartsWith ("file://")) {
112 appBase = appBase.Substring (7);
113 if (Path.DirectorySeparatorChar != '/')
114 appBase = appBase.Replace ('/', Path.DirectorySeparatorChar);
115 if (Environment.IsRunningOnWindows) {
116 // Under Windows prepend "//" to indicate it's a local file
117 appBase = "//" + appBase;
122 // under 1.x the ":" gets a special treatment - but it doesn't make sense outside Windows
123 } else if (!Environment.IsRunningOnWindows || (appBase.IndexOf (':') == -1)) {
125 appBase = Path.GetFullPath (appBase);
131 public string ApplicationBase {
132 get { return GetAppBase (application_base); }
133 set { application_base = value; }
136 public string ApplicationName {
138 return application_name;
141 application_name = value;
145 public string CachePath {
154 public string ConfigurationFile {
156 return configuration_file;
159 configuration_file = value;
163 public bool DisallowPublisherPolicy {
165 return publisher_policy;
168 publisher_policy = value;
172 public string DynamicBase {
174 if (dynamic_base == null)
177 if (Path.IsPathRooted (dynamic_base))
180 if (ApplicationBase == null)
181 throw new MemberAccessException ("The ApplicationBase must be set before retrieving this property.");
183 return Path.Combine (ApplicationBase, dynamic_base);
186 if (application_name == null)
187 throw new MemberAccessException ("ApplicationName must be set before the DynamicBase can be set.");
188 uint id = (uint) application_name.GetHashCode ();
189 dynamic_base = Path.Combine (value, id.ToString("x"));
193 public string LicenseFile {
198 license_file = value;
202 [MonoTODO ("In Mono this is controlled by the --share-code flag")]
203 public LoaderOptimization LoaderOptimization {
205 return loader_optimization;
208 loader_optimization = value;
212 public string PrivateBinPath {
214 return private_bin_path;
217 private_bin_path = value;
222 public string PrivateBinPathProbe {
224 return private_bin_path_probe;
227 private_bin_path_probe = value;
232 public string ShadowCopyDirectories {
234 return shadow_copy_directories;
237 shadow_copy_directories = value;
241 public string ShadowCopyFiles {
243 return shadow_copy_files;
246 shadow_copy_files = value;
251 public bool DisallowBindingRedirects {
253 return disallow_binding_redirects;
256 disallow_binding_redirects = value;
260 public bool DisallowCodeDownload {
262 return disallow_code_downloads;
265 disallow_code_downloads = value;
271 public ActivationArguments ActivationArguments {
272 get { return _activationArguments; }
273 set { _activationArguments = value; }