2 // System.AppDomainSetup.cs
5 // Dietmar Maurer (dietmar@ximian.com)
7 // (C) 2001 Ximian, Inc. http://www.ximian.com
11 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System.Runtime.CompilerServices;
35 using System.Runtime.InteropServices;
40 [ClassInterface (ClassInterfaceType.None)]
41 public sealed class AppDomainSetup : IAppDomainSetup
43 string application_base;
44 string application_name;
46 string configuration_file;
49 string private_bin_path;
50 string private_bin_path_probe;
51 string shadow_copy_directories;
52 string shadow_copy_files;
53 bool publisher_policy;
54 private bool path_changed;
55 private LoaderOptimization loader_optimization;
56 bool disallow_binding_redirects;
57 bool disallow_code_downloads;
59 public AppDomainSetup ()
63 static string GetAppBase (string appBase)
65 if (appBase == null) return null;
66 int len = appBase.Length;
67 if (len >= 8 && appBase.ToLower ().StartsWith ("file://")) {
68 appBase = appBase.Substring (7);
69 if (Path.DirectorySeparatorChar != '/')
70 appBase = appBase.Replace ('/', Path.DirectorySeparatorChar);
72 } else if (appBase.IndexOf (':') == -1) {
73 appBase = Path.GetFullPath (appBase);
79 public string ApplicationBase {
81 return application_base;
84 application_base = GetAppBase (value);
88 public string ApplicationName {
90 return application_name;
93 application_name = value;
97 public string CachePath {
106 public string ConfigurationFile {
108 return configuration_file;
111 configuration_file = value;
115 public bool DisallowPublisherPolicy {
117 return publisher_policy;
120 publisher_policy = value;
124 public string DynamicBase {
126 if (dynamic_base == null)
129 if (Path.IsPathRooted (dynamic_base))
132 if (ApplicationBase == null)
133 throw new MemberAccessException ("The ApplicationBase must be set before retrieving this property.");
135 return Path.Combine (ApplicationBase, dynamic_base);
138 if (application_name == null)
139 throw new MemberAccessException ("ApplicationName must be set before the DynamicBase can be set.");
140 uint id = (uint) application_name.GetHashCode ();
141 dynamic_base = Path.Combine (value, id.ToString("x"));
145 public string LicenseFile {
150 license_file = value;
154 [MonoTODO ("--share-code")]
155 public LoaderOptimization LoaderOptimization {
157 return loader_optimization;
160 loader_optimization = value;
164 public string PrivateBinPath {
166 return private_bin_path;
169 private_bin_path = value;
174 public string PrivateBinPathProbe {
176 return private_bin_path_probe;
179 private_bin_path_probe = value;
184 public string ShadowCopyDirectories {
186 return shadow_copy_directories;
189 shadow_copy_directories = value;
193 public string ShadowCopyFiles {
195 return shadow_copy_files;
198 shadow_copy_files = value;
203 public bool DisallowBindingRedirects {
205 return disallow_binding_redirects;
208 disallow_binding_redirects = value;
212 public bool DisallowCodeDownload {
214 return disallow_code_downloads;
217 disallow_code_downloads = value;