Пример #1
0
            static Uri GetProxyUriFromScript(IntPtr script, Uri targetUri, out NetworkCredential credentials)
            {
                CFProxy[] proxies = CFNetwork.GetProxiesForAutoConfigurationScript(script, targetUri);

                if (proxies == null)
                {
                    credentials = null;
                    return(targetUri);
                }

                for (int i = 0; i < proxies.Length; i++)
                {
                    switch (proxies[i].ProxyType)
                    {
                    case CFProxyType.HTTPS:
                    case CFProxyType.HTTP:
                    case CFProxyType.FTP:
                        // create a Uri based on the hostname/port/etc info
                        return(GetProxyUri(proxies[i], out credentials));

                    case CFProxyType.SOCKS:
                    default:
                        // unsupported proxy type, try the next one
                        break;

                    case CFProxyType.None:
                        // no proxy should be used
                        credentials = null;
                        return(targetUri);
                    }
                }

                credentials = null;

                return(null);
            }
Пример #2
0
 static Uri GetProxyUriFromScript(IntPtr script, Uri targetUri, out NetworkCredential credentials)
 {
     CFProxy[] proxies = CFNetwork.GetProxiesForAutoConfigurationScript(script, targetUri);
     return(SelectProxy(proxies, targetUri, out credentials));
 }