Welcome to mirror list, hosted at ThFree Co, Russian Federation.

GlobalProxySelection.cs « System.Net « System « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d17683ced5ba4d5d7f8851d72e79a1b49b8f1fb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
// System.Net.GlobalProxySelection
//
// Author:
//   Lawrence Pit (loz@cable.a2000.nl)
//

using System;
using System.Collections;
using System.IO;
using System.Runtime.Serialization;

namespace System.Net 
{
	public class GlobalProxySelection
	{
		private static IWebProxy proxy;
		
		// Static Initializer
		
		static GlobalProxySelection ()
		{
			proxy = GetEmptyWebProxy ();
			
			// TODO: create proxy object based on information from
			//       the global or application configuration file.
		}
		
		// Constructors
		
		public GlobalProxySelection() { }
		
		// Properties
		
		public static IWebProxy Select {
			get { return proxy; }
			set { 
				proxy = (value == null) ? GetEmptyWebProxy () : 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
			}
		}
	}		
}