コード例 #1
0
 public static IWebProxy CreateDefaultProxy()
 {
     if (Platform.IsMacOS)
     {
         IWebProxy defaultProxy = CFNetwork.GetDefaultProxy();
         if (defaultProxy != null)
         {
             return(defaultProxy);
         }
         Console.WriteLine("MonoWebProxy.CreateDefaultProxy: No proxy returned from CFNetwork.GetDefaultProxy");
     }
     else
     {
         throw new Exception("MonoWebProxy.CreateDefaultProxy: Platform.IsMacOS is false");
     }
     throw new Exception("MonoWebProxy.CreateDefaultProxy Not expecting this to be run");
 }
コード例 #2
0
        static void CheckMacProxy(Uri uri)
        {
            Console.WriteLine("# Mono's CFNetwork");
            var defaultProxy = CFNetwork.GetDefaultProxy();

            if (defaultProxy != null)
            {
                Console.WriteLine("Got default proxy from CFNetwork.GetDefaultProxy");
                var proxyAddress = new Uri(defaultProxy.GetProxy(uri).AbsoluteUri);
                if (string.Equals(proxyAddress.AbsoluteUri, uri.AbsoluteUri))
                {
                    Console.WriteLine("CFNetwork.GetDefaultProxy. ProxyAddress matches request uri. Ignoring proxy uri: '{0}'", proxyAddress);
                }
                else
                {
                    Console.WriteLine("Found proxy from CFNetwork.GetDefaultProxy. Url '{0}'", proxyAddress.AbsoluteUri);
                }
            }
            Console.WriteLine();
        }
コード例 #3
0
        public MenuDialogViewController() : base(new RootElement(""))
        {
            CFProxySettings proxy0 = CFNetwork.GetSystemProxySettings();
            IWebProxy       proxy1 = WebRequest.GetSystemWebProxy();
            IWebProxy       proxy2 = HttpWebRequest.DefaultWebProxy;
            IWebProxy       proxy3 = HttpWebRequest.GetSystemWebProxy();
            IWebProxy       proxy4 = CFNetwork.GetDefaultProxy();


            RootElement root = new RootElement("");

            root.UnevenRows = true;

            Section section = new Section();

            CFProxySettings proxySettings = CFNetwork.GetSystemProxySettings();

            section.Add(new MultilineElement("HTTPEnable", proxySettings.HTTPEnable.ToString()));
            section.Add(new MultilineElement("HTTPPort", proxySettings.HTTPPort.ToString()));
            section.Add(new MultilineElement("HTTPProxy", (proxySettings.HTTPProxy == null) ? "null" : proxySettings.HTTPProxy.ToString()));
            section.Add(new MultilineElement("ProxyAutoConfigEnable", proxySettings.ProxyAutoConfigEnable.ToString()));
            section.Add(new MultilineElement("ProxyAutoConfigJavaScript", (proxySettings.ProxyAutoConfigJavaScript == null) ? "null" : proxySettings.ProxyAutoConfigJavaScript.ToString()));
            section.Add(new MultilineElement("ProxyAutoConfigURLString", (proxySettings.ProxyAutoConfigURLString == null) ? "null" : proxySettings.ProxyAutoConfigURLString.ToString()));
            root.Add(section);

            foreach (NSString key in proxySettings.Dictionary.Keys)
            {
                section = new Section(key.ToString());
                section.Add(new MultilineElement(proxySettings.Dictionary[key].ToString()));
                root.Add(section);
            }

            StyledStringElement sse;

            section     = new Section();
            sse         = new StyledStringElement("HttpWebRequest");
            sse.Tapped += delegate() {
                Do_HttpWebRequest();
            };
            section.Add(sse);
            root.Add(section);



            section     = new Section();
            sse         = new StyledStringElement("HttpWebRequest DefaultWebProxy()");
            sse.Tapped += delegate() {
                Do_HttpWebRequest_DefaultWebProxy();
            };
            section.Add(sse);
            root.Add(section);



            section     = new Section();
            sse         = new StyledStringElement("WebClient");
            sse.Tapped += delegate() {
                Do_WebClient();
            };
            section.Add(sse);
            root.Add(section);


            section     = new Section();
            sse         = new StyledStringElement("NSData.FromUrl");
            sse.Tapped += delegate() {
                Do_NSData_FromUrl();
            };
            section.Add(sse);
            root.Add(section);


            section     = new Section();
            sse         = new StyledStringElement("NSUrlConnection");
            sse.Tapped += delegate() {
                Do_NSUrlConnection();
            };
            section.Add(sse);
            root.Add(section);


            section     = new Section();
            sse         = new StyledStringElement("DataDownloader");
            sse.Tapped += delegate() {
                Do_DataDownloader();
            };
            section.Add(sse);
            root.Add(section);

            Root = root;
        }