1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 namespace System.Net 6 { 7 [Obsolete("This class has been deprecated. Please use WebRequest.DefaultWebProxy instead to access and set the global default proxy. Use 'null' instead of GetEmptyWebProxy. http://go.microsoft.com/fwlink/?linkid=14202")] 8 public class GlobalProxySelection 9 { 10 // This defers to WebRequest.DefaultWebProxy, but returns EmptyWebProxy instead of null. 11 public static IWebProxy Select 12 { 13 get 14 { 15 IWebProxy proxy = WebRequest.DefaultWebProxy; 16 if (proxy == null) 17 { 18 proxy = GetEmptyWebProxy(); 19 } 20 return proxy; 21 } 22 23 set 24 { 25 WebRequest.DefaultWebProxy = value; 26 } 27 } 28 GetEmptyWebProxy()29 public static IWebProxy GetEmptyWebProxy() 30 { 31 return new EmptyWebProxy(); 32 } 33 34 [Serializable] 35 private sealed class EmptyWebProxy : IWebProxy 36 { 37 private ICredentials _credentials; 38 EmptyWebProxy()39 public EmptyWebProxy() 40 { 41 } 42 GetProxy(Uri uri)43 public Uri GetProxy(Uri uri) 44 { 45 return uri; 46 } 47 IsBypassed(Uri uri)48 public bool IsBypassed(Uri uri) 49 { 50 return true; // no proxy, always bypasses 51 } 52 53 public ICredentials Credentials 54 { 55 get 56 { 57 return _credentials; 58 } 59 set 60 { 61 _credentials = value; // doesn't do anything, but doesn't break contract either 62 } 63 } 64 } 65 } 66 } 67