2 // System.Web.Util.RuntimeHelpers
5 // Marek Habersack (mhabersack@novell.com)
7 // (C) 2006-2010 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.
31 using System
.Collections
.Generic
;
32 using System
.ComponentModel
;
33 using System
.Reflection
;
34 using System
.Web
.Configuration
;
36 namespace System
.Web
.Util
38 static class RuntimeHelpers
40 public static bool CaseInsensitive
{
44 public static bool DebuggingEnabled
{
46 CompilationSection cs
= WebConfigurationManager
.GetSection ("system.web/compilation") as CompilationSection
;
54 public static IEqualityComparer
<string> StringEqualityComparer
{
58 public static IEqualityComparer
<string> StringEqualityComparerCulture
{
62 public static bool IsUncShare
{
66 public static string MonoVersion
{
70 public static bool RunningOnWindows
{
74 public static StringComparison StringComparison
{
78 public static StringComparison StringComparisonCulture
{
82 static RuntimeHelpers ()
84 PlatformID pid
= Environment
.OSVersion
.Platform
;
85 RunningOnWindows
= ((int) pid
!= 128 && pid
!= PlatformID
.Unix
&& pid
!= PlatformID
.MacOSX
);
87 if (RunningOnWindows
) {
88 CaseInsensitive
= true;
89 string appDomainAppPath
= AppDomain
.CurrentDomain
.GetData (".appPath") as string;
90 if (!String
.IsNullOrEmpty (appDomainAppPath
)) {
92 IsUncShare
= new Uri (appDomainAppPath
).IsUnc
;
98 string mono_iomap
= Environment
.GetEnvironmentVariable ("MONO_IOMAP");
99 if (!String
.IsNullOrEmpty (mono_iomap
)) {
100 if (mono_iomap
== "all")
101 CaseInsensitive
= true;
103 string[] parts
= mono_iomap
.Split (':');
104 foreach (string p
in parts
) {
105 if (p
== "all" || p
== "case") {
106 CaseInsensitive
= true;
114 if (CaseInsensitive
) {
115 StringEqualityComparer
= StringComparer
.OrdinalIgnoreCase
;
116 StringEqualityComparerCulture
= StringComparer
.CurrentCultureIgnoreCase
;
117 StringComparison
= StringComparison
.OrdinalIgnoreCase
;
118 StringComparisonCulture
= StringComparison
.CurrentCultureIgnoreCase
;
120 StringEqualityComparer
= StringComparer
.Ordinal
;
121 StringEqualityComparerCulture
= StringComparer
.CurrentCulture
;
122 StringComparison
= StringComparison
.Ordinal
;
123 StringComparisonCulture
= StringComparison
.CurrentCulture
;
126 string monoVersion
= null;
128 Type monoRuntime
= Type
.GetType ("Mono.Runtime", false);
129 if (monoRuntime
!= null) {
130 MethodInfo mi
= monoRuntime
.GetMethod ("GetDisplayName", BindingFlags
.Static
| BindingFlags
.NonPublic
);
132 monoVersion
= mi
.Invoke (null, new object [0]) as string;
138 if (monoVersion
== null)
139 monoVersion
= Environment
.Version
.ToString ();
141 MonoVersion
= monoVersion
;