예제 #1
0
        public static object GetAppValue(string key, NSString applicationId)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            else if (applicationId == null)
            {
                throw new ArgumentNullException("applicationId");
            }

            IntPtr valuePtr;

            using (var cfKey = new CFString(key)) {
                valuePtr = CFPreferencesCopyAppValue(cfKey.Handle, applicationId.Handle);
            }

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

            using (var plist = new CFPropertyList(valuePtr)) {
                return(plist.Value);
            }
        }
예제 #2
0
        public static object GetAppValue(string key, NSString applicationId)
        {
            if (key == null) {
                throw new ArgumentNullException ("key");
            } else if (applicationId == null) {
                throw new ArgumentNullException ("applicationId");
            }

            IntPtr valuePtr;

            using (var cfKey = new CFString (key)) {
                valuePtr = CFPreferencesCopyAppValue (cfKey.Handle, applicationId.Handle);
            }

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

            using (var plist = new CFPropertyList (valuePtr)) {
                return plist.Value;
            }
        }