The Labs \ Source Viewer \ SSCLI \ System.Net \ GlobalProxySelection

  1. //------------------------------------------------------------------------------
  2. // <copyright file="GlobalProxySelection.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.Net
  16. {
  17.     [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")]
  18.     public class GlobalProxySelection
  19.     {
  20.         public static IWebProxy Select {
  21.             get {
  22.                 IWebProxy proxy = WebRequest.DefaultWebProxy;
  23.                 if (proxy == null) {
  24.                     return GetEmptyWebProxy();
  25.                 }
  26.                 WebRequest.WebProxyWrapper wrap = proxy as WebRequest.WebProxyWrapper;
  27.                 if (wrap != null) {
  28.                     return wrap.WebProxy;
  29.                 }
  30.                 return proxy;
  31.             }
  32.            
  33.             set { WebRequest.DefaultWebProxy = value; }
  34.         }
  35.        
  36.         public static IWebProxy GetEmptyWebProxy()
  37.         {
  38.             return new EmptyWebProxy();
  39.         }
  40.     }
  41. }

Developer Fusion