Esempio n. 1
0
        //
        // Uses this object, by instancing, and retrieves
        //  the proxy settings from IE = converts to URI
        //
        static internal WebProxy GetIEProxy()
        {
            bool         isLocalOverride  = false;
            ProxyRegBlob proxyIE5Settings = new ProxyRegBlob();
            Hashtable    proxyHashTable   = null;

            string [] bypassList = null;
            Uri       proxyUri   = null;

            if (!ComNetOS.IsAspNetServer &&
                proxyIE5Settings.ReadRegSettings() &&
                proxyIE5Settings.ReadInt32() >= ProxyRegBlob.IE50StrucSize)
            {
                // read the rest of the items out

                proxyIE5Settings.ReadInt32();                             // current settings version

                int    proxyFlags        = proxyIE5Settings.ReadInt32();  // flags
                string proxyUriString    = proxyIE5Settings.ReadString(); // proxy name
                string proxyBypassString = proxyIE5Settings.ReadString(); // proxy bypass

                // If we need the additional things, keep reading sequentially
                //proxyIE5Settings.ReadString(); // autoconfig url
                //proxyIE5Settings.ReadInt32(); // autodetect flags
                //proxyIE5Settings.ReadString(); // last known good auto-prxy url
                // otherwise...

                //
                // Once we verify that the flag for proxy is enabled,
                // Parse UriString that is stored, may be in the form,
                //  of "http=http://http-proxy;ftp="ftp=http://..." must
                //  handle this case along with just a URI.
                //

                if ((ProxyRegBlob.IE50ProxyFlag & proxyFlags) == ProxyRegBlob.IE50ProxyFlag)
                {
                    try {
                        proxyUri = ParseProxyUri(proxyUriString, true);
                        if (proxyUri == null)
                        {
                            proxyHashTable = ParseProtocolProxies(proxyUriString);
                        }

                        if ((proxyUri != null || proxyHashTable != null) && proxyBypassString != null)
                        {
                            bypassList = ParseBypassList(proxyBypassString, out isLocalOverride);
                        }

                        // success if we reach here
                    } catch (Exception) {
                    }
                }
            }

            WebProxy webProxy = null;

            if (proxyHashTable != null)
            {
                webProxy = new WebProxy((Uri)proxyHashTable["http"], isLocalOverride, bypassList);
            }
            else
            {
                webProxy = new WebProxy(proxyUri, isLocalOverride, bypassList);
            }

            return(webProxy);
        }
Esempio n. 2
0
 /// <include file='doc\webproxy.uex' path='docs/doc[@for="WebProxy.GetDefaultProxy"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public static WebProxy GetDefaultProxy()
 {
     (new WebPermission(PermissionState.Unrestricted)).Demand();
     return(ProxyRegBlob.GetIEProxy());
 }
Esempio n. 3
0
 /// <include file='doc\webproxy.uex' path='docs/doc[@for="WebProxy.GetDefaultProxy"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public static WebProxy GetDefaultProxy()
 {
     return(ProxyRegBlob.GetIEProxy());
 }