2002-10-03 Dick Porter <dick@ximian.com>
[mono.git] / mcs / class / System / System.Net / GlobalProxySelection.cs
1 //\r
2 // System.Net.GlobalProxySelection\r
3 //\r
4 // Author:\r
5 //   Lawrence Pit (loz@cable.a2000.nl)\r
6 //\r
7 \r
8 using System;\r
9 using System.Collections;\r
10 using System.IO;\r
11 using System.Runtime.Serialization;\r
12 \r
13 namespace System.Net \r
14 {\r
15         public class GlobalProxySelection\r
16         {\r
17                 private static IWebProxy proxy;\r
18                 \r
19                 // Static Initializer\r
20                 \r
21                 static GlobalProxySelection ()\r
22                 {\r
23                         proxy = GetEmptyWebProxy ();\r
24                         \r
25                         // TODO: create proxy object based on information from\r
26                         //       the global or application configuration file.\r
27                 }\r
28                 \r
29                 // Constructors\r
30                 \r
31                 public GlobalProxySelection() { }\r
32                 \r
33                 // Properties\r
34                 \r
35                 public static IWebProxy Select {\r
36                         get { return proxy; }\r
37                         set { \r
38                                 proxy = (value == null) ? GetEmptyWebProxy () : value; \r
39                         }\r
40                 }\r
41                 \r
42                 // Methods\r
43                 \r
44                 public static IWebProxy GetEmptyWebProxy()\r
45                 {\r
46                         // must return a new one each time, as the credentials\r
47                         // can be set\r
48                         return new EmptyWebProxy ();    \r
49                 }\r
50                 \r
51                 // Internal Classes\r
52                 \r
53                 internal class EmptyWebProxy : IWebProxy {\r
54                         private ICredentials credentials = null;\r
55                         \r
56                         internal EmptyWebProxy () { }\r
57                         \r
58                         public ICredentials Credentials {\r
59                                 get { return credentials; } \r
60                                 set { credentials = value; }\r
61                         }\r
62 \r
63                         public Uri GetProxy (Uri destination)\r
64                         {\r
65                                 return destination;\r
66                         }\r
67 \r
68                         public bool IsBypassed (Uri host)\r
69                         {\r
70                                 return true; // pass directly to host\r
71                         }\r
72                 }\r
73         }               \r
74 }