예제 #1
0
        public static CFProxy[] ExecuteProxyAutoConfigurationURL(IntPtr proxyAutoConfigURL, Uri targetURL)
        {
            CFUrl url = CFUrl.Create(targetURL.AbsoluteUri);

            if (url == null)
            {
                return(null);
            }

            CFProxy[] proxies = null;

            var runLoop = CFRunLoop.CurrentRunLoop;

            // Callback that will be called after executing the configuration script
            CFProxyAutoConfigurationResultCallback cb = delegate(IntPtr client, IntPtr proxyList, IntPtr error) {
                if (proxyList != IntPtr.Zero)
                {
                    var array = new CFArray(proxyList, false);
                    proxies = new CFProxy [array.Count];
                    for (int i = 0; i < proxies.Length; i++)
                    {
                        CFDictionary dict = new CFDictionary(array[i], false);
                        proxies[i] = new CFProxy(dict);
                    }
                    array.Dispose();
                }
                runLoop.Stop();
            };

            var clientContext = new CFStreamClientContext();
            var loopSource    = CFNetworkExecuteProxyAutoConfigurationURL(proxyAutoConfigURL, url.Handle, cb, ref clientContext);

            // Create a private mode
            var mode = CFString.Create("Mono.MacProxy");

            runLoop.AddSource(loopSource, mode);
            runLoop.RunInMode(mode, double.MaxValue, false);
            runLoop.RemoveSource(loopSource, mode);

            return(proxies);
        }
예제 #2
0
파일: MacProxy.cs 프로젝트: Profit0004/mono
		public static CFProxy[] ExecuteProxyAutoConfigurationURL (IntPtr proxyAutoConfigURL, Uri targetURL)
		{
			CFUrl url = CFUrl.Create (targetURL.AbsoluteUri);
			if (url == null)
				return null;

			CFProxy[] proxies = null;

			var runLoop = CFRunLoop.CurrentRunLoop;

			// Callback that will be called after executing the configuration script
			CFProxyAutoConfigurationResultCallback cb = delegate (IntPtr client, IntPtr proxyList, IntPtr error) {
				if (proxyList != IntPtr.Zero) {
					var array = new CFArray (proxyList, false);
					proxies = new CFProxy [array.Count];
					for (int i = 0; i < proxies.Length; i++) {
						CFDictionary dict = new CFDictionary (array[i], false);
						proxies[i] = new CFProxy (dict);
					}
					array.Dispose ();
				}
				runLoop.Stop ();
			};

			var clientContext = new CFStreamClientContext ();
			var loopSource = CFNetworkExecuteProxyAutoConfigurationURL (proxyAutoConfigURL, url.Handle, cb, ref clientContext);

			// Create a private mode
			var mode = CFString.Create ("Mono.MacProxy");

			runLoop.AddSource (loopSource, mode);
			runLoop.RunInMode (mode, double.MaxValue, false);
			runLoop.RemoveSource (loopSource, mode);

			return proxies;
		}
예제 #3
0
 extern static IntPtr CFNetworkExecuteProxyAutoConfigurationURL(IntPtr proxyAutoConfigURL, IntPtr targetURL, CFProxyAutoConfigurationResultCallback cb, ref CFStreamClientContext clientContext);
예제 #4
0
파일: MacProxy.cs 프로젝트: Profit0004/mono
		extern static IntPtr CFNetworkExecuteProxyAutoConfigurationURL (IntPtr proxyAutoConfigURL, IntPtr targetURL, CFProxyAutoConfigurationResultCallback cb, ref CFStreamClientContext clientContext);