GlobalProxySelection.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / GlobalProxySelection.cs / 1305376 / GlobalProxySelection.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Net 
{ 
    [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")]
    public class GlobalProxySelection 
    {
        // This just wraps WebRequest.DefaultWebProxy and modifies it to be compatible with Everett.
        // It needs to return a WebProxy whenever possible, and an EmptyWebProxy instead of null.
        public static IWebProxy Select 
        {
            get 
            { 
                IWebProxy proxy = WebRequest.DefaultWebProxy;
                if (proxy == null) 
                {
                    return GetEmptyWebProxy();
                }
                WebRequest.WebProxyWrapper wrap = proxy as WebRequest.WebProxyWrapper; 
                if (wrap != null)
                { 
                    return wrap.WebProxy; 
                }
                return proxy; 
            }

            set
            { 
                WebRequest.DefaultWebProxy = value;
            } 
        } 

        public static IWebProxy GetEmptyWebProxy() { 
            return new EmptyWebProxy();
        }
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK