Merge pull request #2171 from lambdageek/dev/fix-marshal
[mono.git] / mcs / class / System / System.Net / GlobalProxySelection.cs
index ac5a23b5b61f23abfbd739cea2822d7304cabcd2..049f61ccad047c2331a06cc0ef2148213cb88bb9 100644 (file)
@@ -1,88 +1,83 @@
-//\r
-// System.Net.GlobalProxySelection\r
-//\r
-// Author:\r
-//   Lawrence Pit (loz@cable.a2000.nl)\r
-//\r
-\r
-using System;\r
-using System.Collections;\r
-using System.Configuration;\r
-using System.IO;\r
-using System.Runtime.Serialization;\r
-\r
-namespace System.Net \r
-{\r
-       public class GlobalProxySelection\r
-       {\r
-               private static IWebProxy proxy;\r
-               \r
-               // Constructors\r
-               public GlobalProxySelection() { }\r
-               \r
-               // Properties\r
-               \r
-               static IWebProxy GetProxy ()\r
-               {\r
-                       if (proxy != null)\r
-                               return proxy;\r
-\r
-                       lock (typeof (GlobalProxySelection)) {\r
-                               if (proxy != null)\r
-                                       return proxy;\r
-\r
-                               object p = ConfigurationSettings.GetConfig ("system.net/defaultProxy");\r
-                               if (p == null)\r
-                                       p = new EmptyWebProxy ();\r
-\r
-                               proxy = (IWebProxy) p;\r
-                       }\r
-\r
-                       return proxy;\r
-               }\r
-               \r
-               public static IWebProxy Select {\r
-                       get { return GetProxy (); }\r
-                       set {\r
-                               if (value == null)\r
-                                       throw new ArgumentNullException ("GlobalProxySelection.Select",\r
-                                                       "null IWebProxy not allowed. Use GetEmptyWebProxy ()");\r
-\r
-                               lock (typeof (GlobalProxySelection))\r
-                                       proxy = value; \r
-                       }\r
-               }\r
-               \r
-               // Methods\r
-               \r
-               public static IWebProxy GetEmptyWebProxy()\r
-               {\r
-                       // must return a new one each time, as the credentials\r
-                       // can be set\r
-                       return new EmptyWebProxy ();    \r
-               }\r
-               \r
-               // Internal Classes\r
-               \r
-               internal class EmptyWebProxy : IWebProxy {\r
-                       private ICredentials credentials = null;\r
-                       \r
-                       internal EmptyWebProxy () { }\r
-                       \r
-                       public ICredentials Credentials {\r
-                               get { return credentials; } \r
-                               set { credentials = value; }\r
-                       }\r
-\r
-                       public Uri GetProxy (Uri destination)\r
-                       {\r
-                               return destination;\r
-                       }\r
-\r
-                       public bool IsBypassed (Uri host)\r
-                       {\r
-                               return true; // pass directly to host\r
-                       }\r
-               }\r
-       }               \r
-}\r
+//
+// System.Net.GlobalProxySelection
+//
+// Author:
+//   Lawrence Pit (loz@cable.a2000.nl)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Configuration;
+using System.IO;
+using System.Runtime.Serialization;
+using System.Net.Configuration;
+
+namespace System.Net 
+{
+       [ObsoleteAttribute("Use WebRequest.DefaultProxy instead")]
+       public class GlobalProxySelection
+       {
+               // Constructors
+               public GlobalProxySelection() { }
+               
+               // Properties
+
+               public static IWebProxy Select {
+                       get { return WebRequest.DefaultWebProxy; }
+                       set { WebRequest.DefaultWebProxy = value; }
+               }
+               
+               // Methods
+               
+               public static IWebProxy GetEmptyWebProxy()
+               {
+                       // must return a new one each time, as the credentials
+                       // can be set
+                       return new EmptyWebProxy ();    
+               }
+               
+               // Internal Classes
+               
+               internal class EmptyWebProxy : IWebProxy {
+                       private ICredentials credentials = null;
+                       
+                       internal EmptyWebProxy () { }
+                       
+                       public ICredentials Credentials {
+                               get { return credentials; } 
+                               set { credentials = value; }
+                       }
+
+                       public Uri GetProxy (Uri destination)
+                       {
+                               return destination;
+                       }
+
+                       public bool IsBypassed (Uri host)
+                       {
+                               return true; // pass directly to host
+                       }
+               }
+       }               
+}