-//\r
-// System.Net.GlobalProxySelection\r
-//\r
-// Author:\r
-// Lawrence Pit (loz@cable.a2000.nl)\r
-//\r
+//
+// System.Net.GlobalProxySelection
+//
+// Author:
+// Lawrence Pit (loz@cable.a2000.nl)
+//
//
// Permission is hereby granted, free of charge, to any person obtaining
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-\r
-using System;\r
-using System.Collections;\r
-using System.Configuration;\r
-using System.IO;\r
-using System.Runtime.Serialization;\r
-#if NET_2_0\r
-using System.Net.Configuration;\r
-#endif\r
-\r
-namespace System.Net \r
-{\r
- public class GlobalProxySelection\r
- {\r
- volatile static IWebProxy proxy;
- static readonly object lockobj = new object ();\r
- \r
- // Constructors\r
- public GlobalProxySelection() { }\r
- \r
- // Properties\r
- \r
- static IWebProxy GetProxy ()\r
- {\r
- lock (lockobj) {\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
-#if NET_2_0 && CONFIGURATION_DEP\r
- DefaultProxySection s = p as DefaultProxySection;\r
- if (s != null) {\r
- // FIXME: handle Module\r
- ProxyElement e = s.Proxy;\r
- // FIXME: handle AutoDetect, ScriptLocation, UseSystemDefault\r
- if (e.BypassOnLocal == ProxyElement.BypassOnLocalValues.Unspecified)\r
- p = new WebProxy (e.ProxyAddress);\r
- else\r
- p = new WebProxy (e.ProxyAddress, e.BypassOnLocal == ProxyElement.BypassOnLocalValues.True);\r
- }\r
-#endif\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
- 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
+
+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
+ }
+ }
+ }
+}