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); } }
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(); } } }
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 (); } }
public bool ContainsKey(string key) { using (var str = new CFString(key)) { return(CFDictionaryContainsKey(Handle, str.Handle)); } }
public IntPtr GetIntPtrValue(string key) { using (var str = new CFString(key)) { return(CFDictionaryGetValue(Handle, str.Handle)); } }
// 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 (); } } }
public IntPtr GetIntPtrValue(string key) { using (var str = new CFString (key)) { return CFDictionaryGetValue (Handle, str.Handle); } }
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; } }
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); } }
public bool ContainsKey(string key) { using (var str = new CFString (key)) { return CFDictionaryContainsKey (Handle, str.Handle); } }