2 // System.Net.GlobalProxySelection
\r
5 // Lawrence Pit (loz@cable.a2000.nl)
\r
9 using System.Collections;
\r
10 using System.Configuration;
\r
12 using System.Runtime.Serialization;
\r
14 namespace System.Net
\r
16 public class GlobalProxySelection
\r
18 private static IWebProxy proxy;
\r
21 public GlobalProxySelection() { }
\r
25 static IWebProxy GetProxy ()
\r
30 lock (typeof (GlobalProxySelection)) {
\r
34 object p = ConfigurationSettings.GetConfig ("system.net/defaultProxy");
\r
36 p = new EmptyWebProxy ();
\r
38 proxy = (IWebProxy) p;
\r
44 public static IWebProxy Select {
\r
45 get { return GetProxy (); }
\r
48 throw new ArgumentNullException ("GlobalProxySelection.Select",
\r
49 "null IWebProxy not allowed. Use GetEmptyWebProxy ()");
\r
51 lock (typeof (GlobalProxySelection))
\r
58 public static IWebProxy GetEmptyWebProxy()
\r
60 // must return a new one each time, as the credentials
\r
62 return new EmptyWebProxy ();
\r
67 internal class EmptyWebProxy : IWebProxy {
\r
68 private ICredentials credentials = null;
\r
70 internal EmptyWebProxy () { }
\r
72 public ICredentials Credentials {
\r
73 get { return credentials; }
\r
74 set { credentials = value; }
\r
77 public Uri GetProxy (Uri destination)
\r
82 public bool IsBypassed (Uri host)
\r
84 return true; // pass directly to host
\r