Esempio n. 1
0
        public static StatusCode TryCopyCurrentNetworkInfo(string interfaceName, out NSDictionary currentNetworkInfo)
        {
            using (var nss = new NSString (interfaceName)) {
                var ni = CNCopyCurrentNetworkInfo (nss.Handle);
                if (ni == IntPtr.Zero) {
                    currentNetworkInfo = null;
                    return StatusCodeError.SCError ();
                }

                currentNetworkInfo = new NSDictionary (ni);

                // Must release since the IntPtr constructor calls Retain
                currentNetworkInfo.DangerousRelease ();
                return StatusCode.OK;
            }
        }
Esempio n. 2
0
        public static CFProxySettings GetSystemProxySettings()
        {
            IntPtr native = CFNetworkCopySystemProxySettings();

            if (native == IntPtr.Zero)
            {
                return(null);
            }

            var dict = new NSDictionary(native);

            // Must release since the IntPtr constructor calls Retain and
            // CFNetworkCopySystemProxySettings return value is already retained
            dict.DangerousRelease();
            return(new CFProxySettings(dict));
        }
Esempio n. 3
0
        static public StatusCode TryCopyCurrentNetworkInfo(string interfaceName, out NSDictionary currentNetworkInfo)
        {
            using (var nss = new NSString(interfaceName)) {
                var ni = CNCopyCurrentNetworkInfo(nss.Handle);
                if (ni == IntPtr.Zero)
                {
                    currentNetworkInfo = null;
                    return(StatusCodeError.SCError());
                }

                currentNetworkInfo = new NSDictionary(ni);

                // Must release since the IntPtr constructor calls Retain
                currentNetworkInfo.DangerousRelease();
                return(StatusCode.OK);
            }
        }
Esempio n. 4
0
        public static CFProxySettings GetSystemProxySettings()
        {
            IntPtr native = CFNetworkCopySystemProxySettings ();

            if (native == IntPtr.Zero)
                return null;

            var dict = new NSDictionary (native);
            // Must release since the IntPtr constructor calls Retain and
            // CFNetworkCopySystemProxySettings return value is already retained
            dict.DangerousRelease ();
            return new CFProxySettings (dict);
        }