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 [MonoTODO ("Fix serialization compatibility with MS.NET")]
42 public sealed class AppDomainSetup
: IAppDomainSetup
44 string application_base
;
45 string application_name
;
47 string configuration_file
;
50 string private_bin_path
;
51 string private_bin_path_probe
;
52 string shadow_copy_directories
;
53 string shadow_copy_files
;
54 bool publisher_policy
;
55 private bool path_changed
;
56 private LoaderOptimization loader_optimization
;
57 bool disallow_binding_redirects
;
58 bool disallow_code_downloads
;
60 public AppDomainSetup ()
64 internal AppDomainSetup (AppDomainSetup setup
)
66 application_base
= setup
.application_base
;
67 application_name
= setup
.application_name
;
68 cache_path
= setup
.cache_path
;
69 configuration_file
= setup
.configuration_file
;
70 dynamic_base
= setup
.dynamic_base
;
71 license_file
= setup
.license_file
;
72 private_bin_path
= setup
.private_bin_path
;
73 private_bin_path_probe
= setup
.private_bin_path_probe
;
74 shadow_copy_directories
= setup
.shadow_copy_directories
;
75 shadow_copy_files
= setup
.shadow_copy_files
;
76 publisher_policy
= setup
.publisher_policy
;
77 path_changed
= setup
.path_changed
;
78 loader_optimization
= setup
.loader_optimization
;
79 disallow_binding_redirects
= setup
.disallow_binding_redirects
;
80 disallow_code_downloads
= setup
.disallow_code_downloads
;
83 static string GetAppBase (string appBase
)
85 if (appBase
== null) return null;
86 int len
= appBase
.Length
;
87 if (len
>= 8 && appBase
.ToLower ().StartsWith ("file://")) {
88 appBase
= appBase
.Substring (7);
89 if (Path
.DirectorySeparatorChar
!= '/')
90 appBase
= appBase
.Replace ('/', Path
.DirectorySeparatorChar
);
92 } else if (appBase
.IndexOf (':') == -1) {
93 appBase
= Path
.GetFullPath (appBase
);
99 public string ApplicationBase
{
101 return application_base
;
104 application_base
= GetAppBase (value);
108 public string ApplicationName
{
110 return application_name
;
113 application_name
= value;
117 public string CachePath
{
126 public string ConfigurationFile
{
128 return configuration_file
;
131 configuration_file
= value;
135 public bool DisallowPublisherPolicy
{
137 return publisher_policy
;
140 publisher_policy
= value;
144 public string DynamicBase
{
146 if (dynamic_base
== null)
149 if (Path
.IsPathRooted (dynamic_base
))
152 if (ApplicationBase
== null)
153 throw new MemberAccessException ("The ApplicationBase must be set before retrieving this property.");
155 return Path
.Combine (ApplicationBase
, dynamic_base
);
158 if (application_name
== null)
159 throw new MemberAccessException ("ApplicationName must be set before the DynamicBase can be set.");
160 uint id
= (uint) application_name
.GetHashCode ();
161 dynamic_base
= Path
.Combine (value, id
.ToString("x"));
165 public string LicenseFile
{
170 license_file
= value;
174 [MonoTODO ("--share-code")]
175 public LoaderOptimization LoaderOptimization
{
177 return loader_optimization
;
180 loader_optimization
= value;
184 public string PrivateBinPath
{
186 return private_bin_path
;
189 private_bin_path
= value;
194 public string PrivateBinPathProbe
{
196 return private_bin_path_probe
;
199 private_bin_path_probe
= value;
204 public string ShadowCopyDirectories
{
206 return shadow_copy_directories
;
209 shadow_copy_directories
= value;
213 public string ShadowCopyFiles
{
215 return shadow_copy_files
;
218 shadow_copy_files
= value;
223 public bool DisallowBindingRedirects
{
225 return disallow_binding_redirects
;
228 disallow_binding_redirects
= value;
232 public bool DisallowCodeDownload
{
234 return disallow_code_downloads
;
237 disallow_code_downloads
= value;