Ejemplo n.º 1
0
//		struct CFDictionaryKeyCallBacks {
//			CFIndex version;
//			CFDictionaryRetainCallBack retain;
//			CFDictionaryReleaseCallBack release;
//			CFDictionaryCopyDescriptionCallBack copyDescription;
//			CFDictionaryEqualCallBack equal;
//			CFDictionaryHashCallBack hash;
//		};
//
//		struct CFDictionaryValueCallBacks {
//			CFIndex version;
//			CFDictionaryRetainCallBack retain;
//			CFDictionaryReleaseCallBack release;
//			CFDictionaryCopyDescriptionCallBack copyDescription;
//			CFDictionaryEqualCallBack equal;
//		};

        // use kCFTypeDictionaryKeyCallBacks and kCFTypeDictionaryValueCallBacks

        // CFDictionaryRef CFDictionaryCreate (CFAllocatorRef allocator, const void **keys, const void **values, CFIndex numValues, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
        // CFMutableDictionaryRef CFDictionaryCreateMutable (CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);

        // void CFDictionaryAddValue (CFMutableDictionaryRef theDict, const void *key, const void *value);

        #endregion

        static string GetError(OSStatus status)
        {
            IntPtr str = IntPtr.Zero;

            try {
                str = SecCopyErrorMessageString(status, IntPtr.Zero);
                return(CFStringGetString(str));
            } catch {
                return(status.ToString());
            } finally {
                if (str != IntPtr.Zero)
                {
                    CFRelease(str);
                }
            }
        }
Ejemplo n.º 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();
                }
            }
        }
Ejemplo n.º 3
0
 public MacOSException(OSStatus errorCode)
     : base("Error Code " + ((int)errorCode).ToString() + ": " + errorCode.ToString())
 {
     this.ErrorCode = errorCode;
 }
Ejemplo n.º 4
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 ();
            }
        }
Ejemplo n.º 5
0
//		struct CFDictionaryKeyCallBacks {
//			CFIndex version;
//			CFDictionaryRetainCallBack retain;
//			CFDictionaryReleaseCallBack release;
//			CFDictionaryCopyDescriptionCallBack copyDescription;
//			CFDictionaryEqualCallBack equal;
//			CFDictionaryHashCallBack hash;
//		};
//
//		struct CFDictionaryValueCallBacks {
//			CFIndex version;
//			CFDictionaryRetainCallBack retain;
//			CFDictionaryReleaseCallBack release;
//			CFDictionaryCopyDescriptionCallBack copyDescription;
//			CFDictionaryEqualCallBack equal;
//		};

		// use kCFTypeDictionaryKeyCallBacks and kCFTypeDictionaryValueCallBacks

		// CFDictionaryRef CFDictionaryCreate (CFAllocatorRef allocator, const void **keys, const void **values, CFIndex numValues, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
		// CFMutableDictionaryRef CFDictionaryCreateMutable (CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);

		// void CFDictionaryAddValue (CFMutableDictionaryRef theDict, const void *key, const void *value);

		#endregion

		static string GetError (OSStatus status)
		{
			IntPtr str = IntPtr.Zero;
			try {
				str = SecCopyErrorMessageString (status, IntPtr.Zero);
				return CFStringGetString (str);
			} catch {
				return status.ToString ();
			} finally {
				if (str != IntPtr.Zero)
					CFRelease (str);
			}
		}
Ejemplo n.º 6
0
 public MacOSException(OSStatus errorCode)
     : base("Error Code " + ((int)errorCode).ToString() + ": " + errorCode.ToString())
 {
     this.errorCode = errorCode;
 }