Beispiel #1
0
        public int GetInt32Value(string key)
        {
            int value = 0;

            using (var str = new CFString(key)) {
                if (!CFNumberGetValue(CFDictionaryGetValue(Handle, str.Handle), /* kCFNumberSInt32Type */ 3, out value))
                {
                    throw new System.Collections.Generic.KeyNotFoundException(string.Format("Key {0} not found", key));
                }
                return(value);
            }
        }
Beispiel #2
0
        static string GetError(OSStatus status)
        {
            CFString str = null;

            try {
                str = new CFString(SecCopyErrorMessageString(status, IntPtr.Zero), true);
                return(str.ToString());
            } catch {
                return(status.ToString());
            } finally {
                if (str != null)
                {
                    str.Dispose();
                }
            }
        }
Beispiel #3
0
        static string GetError(OSStatus status)
        {
            CFString str = null;

            try {
                str = new CFString (SecCopyErrorMessageString (status, IntPtr.Zero), true);
                return str.ToString ();
            } catch {
                return status.ToString ();
            } finally {
                if (str != null)
                    str.Dispose ();
            }
        }
Beispiel #4
0
 public bool ContainsKey(string key)
 {
     using (var str = new CFString(key)) {
         return(CFDictionaryContainsKey(Handle, str.Handle));
     }
 }
Beispiel #5
0
 public IntPtr GetIntPtrValue(string key)
 {
     using (var str = new CFString(key)) {
         return(CFDictionaryGetValue(Handle, str.Handle));
     }
 }
Beispiel #6
0
 //        public static bool GetBooleanValue (IntPtr theDict, IntPtr key)
 //        {
 //            var value = GetValue (theDict, key);
 //            if (value == IntPtr.Zero)
 //                return false;
 //            return CFBoolean.GetValue (value);
 //        }
 public string GetStringValue(string key)
 {
     using (var str = new CFString (key)) {
         using (var value = new CFString (CFDictionaryGetValue (Handle, str.Handle))) {
             return value.ToString ();
         }
     }
 }
Beispiel #7
0
 public IntPtr GetIntPtrValue(string key)
 {
     using (var str = new CFString (key)) {
         return CFDictionaryGetValue (Handle, str.Handle);
     }
 }
Beispiel #8
0
 public int GetInt32Value(string key)
 {
     int value = 0;
     using (var str = new CFString (key)) {
         if (!CFNumberGetValue (CFDictionaryGetValue (Handle, str.Handle), /* kCFNumberSInt32Type */ 3, out value))
             throw new System.Collections.Generic.KeyNotFoundException (string.Format ("Key {0} not found", key));
         return value;
     }
 }
Beispiel #9
0
 public CFDictionary GetDictionaryValue(string key)
 {
     using (var str = new CFString (key)) {
         var ptr = CFDictionaryGetValue (Handle, str.Handle);
         return ptr == IntPtr.Zero ? null : new CFDictionary (ptr);
     }
 }
Beispiel #10
0
 public bool ContainsKey(string key)
 {
     using (var str = new CFString (key)) {
         return CFDictionaryContainsKey (Handle, str.Handle);
     }
 }