X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2Fcorlib%2FSystem%2FEnvironment.cs;h=36ae8687aae76a3cf40e67ae5f76c4dc32993fed;hb=7dc4bb5acadd3e538083604d69da11df815eddc3;hp=dcfe35c85fc8899c4bf94d62686b272cfce0e50c;hpb=95e805c52a5be95fd4ca1cae9f35238d5a2416c4;p=mono.git diff --git a/mcs/class/corlib/System/Environment.cs b/mcs/class/corlib/System/Environment.cs index dcfe35c85fc..36ae8687aae 100644 --- a/mcs/class/corlib/System/Environment.cs +++ b/mcs/class/corlib/System/Environment.cs @@ -57,7 +57,7 @@ namespace System { * of icalls, do not require an increment. */ #pragma warning disable 169 - private const int mono_corlib_version = 150; + private const int mono_corlib_version = 153; #pragma warning restore 169 [ComVisible (true)] @@ -322,7 +322,7 @@ namespace System { return trace.ToString (); } } -#if !NET_2_1 +#if !MOBILE /// /// Get a fully qualified path to the system directory /// @@ -472,7 +472,15 @@ namespace System { public extern static string[] GetCommandLineArgs (); [MethodImplAttribute (MethodImplOptions.InternalCall)] - internal extern static string internalGetEnvironmentVariable (string variable); + internal extern static string internalGetEnvironmentVariable_native (IntPtr variable); + + internal static string internalGetEnvironmentVariable (string variable) { + if (variable == null) + return null; + using (var h = Mono.RuntimeMarshal.MarshalString (variable)) { + return internalGetEnvironmentVariable_native (h.Value); + } + } /// /// Return a string containing the value of the environment @@ -480,7 +488,7 @@ namespace System { /// public static string GetEnvironmentVariable (string variable) { -#if !NET_2_1 +#if !MOBILE if (SecurityManager.SecurityEnabled) { new EnvironmentPermission (EnvironmentPermissionAccess.Read, variable).Demand (); } @@ -503,7 +511,7 @@ namespace System { /// /// Return a set of all environment variables and their values /// -#if !NET_2_1 +#if !MOBILE public static IDictionary GetEnvironmentVariables () { StringBuilder sb = null; @@ -565,7 +573,7 @@ namespace System { else dir = UnixGetFolderPath (folder, option); -#if !NET_2_1 +#if !MOBILE if ((dir != null) && (dir.Length > 0) && SecurityManager.SecurityEnabled) { new FileIOPermission (FileIOPermissionAccess.PathDiscovery, dir).Demand (); } @@ -862,6 +870,22 @@ namespace System { } } #else + public static string GetEnvironmentVariable (string variable, EnvironmentVariableTarget target) + { + if (target == EnvironmentVariableTarget.Process) + return GetEnvironmentVariable (variable); + + return null; + } + + public static IDictionary GetEnvironmentVariables (EnvironmentVariableTarget target) + { + if (target == EnvironmentVariableTarget.Process) + return GetEnvironmentVariables (); + + return (IDictionary)new Hashtable (); + } + public static void SetEnvironmentVariable (string variable, string value) { if (variable == null) @@ -875,6 +899,14 @@ namespace System { InternalSetEnvironmentVariable (variable, value); } + + public static void SetEnvironmentVariable (string variable, string value, EnvironmentVariableTarget target) + { + if (target == EnvironmentVariableTarget.Process) + SetEnvironmentVariable (variable, value); + + // other targets ignored + } #endif [MethodImplAttribute (MethodImplOptions.InternalCall)] internal static extern void InternalSetEnvironmentVariable (string variable, string value); @@ -893,7 +925,9 @@ namespace System { [SecurityCritical] public static void FailFast (string message, Exception exception) { - throw new NotImplementedException (); +#pragma warning disable 618 + throw new ExecutionEngineException (message, exception); +#pragma warning restore } [MethodImplAttribute (MethodImplOptions.InternalCall)] @@ -927,7 +961,7 @@ namespace System { } #endif -#if !NET_2_1 +#if !MOBILE // // Used by gacutil.exe //