[mobile] Add support for Environment.SetEnvironmentVariable in the mobile profile...
authorSebastien Pouliot <sebastien@xamarin.com>
Thu, 29 May 2014 19:29:52 +0000 (15:29 -0400)
committerSebastien Pouliot <sebastien@xamarin.com>
Thu, 29 May 2014 19:29:52 +0000 (15:29 -0400)
mcs/class/corlib/System/Environment.cs

index 13d63ccc129d66740dc1148e997d36aa5b2b7d46..122606212391a547dfc5f8b65547016ab8c02fe1 100644 (file)
@@ -715,7 +715,7 @@ namespace System {
                        return GetLogicalDrivesInternal ();
                }
 
-#if !NET_2_1
+#if !MOBILE
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                private static extern void internalBroadcastSettingChange ();
 
@@ -826,10 +826,24 @@ namespace System {
                                throw new ArgumentException ("target");
                        }
                }
+#else
+               public static void SetEnvironmentVariable (string variable, string value)
+               {
+                       if (variable == null)
+                               throw new ArgumentNullException ("variable");
+                       if (variable == String.Empty)
+                               throw new ArgumentException ("String cannot be of zero length.", "variable");
+                       if (variable.IndexOf ('=') != -1)
+                               throw new ArgumentException ("Environment variable name cannot contain an equal character.", "variable");
+                       if (variable[0] == '\0')
+                               throw new ArgumentException ("The first char in the string is the null character.", "variable");
 
+                       InternalSetEnvironmentVariable (variable, value);
+               }
+#endif
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                internal static extern void InternalSetEnvironmentVariable (string variable, string value);
-#endif
+
                [SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode=true)]
                public static void FailFast (string message)
                {