Esempio n. 1
0
        /// <summary>
        /// Converts a CF type to a managed type (e.g., CFString to String)
        /// </summary>
        /// <param name="Source"></param>
        /// <returns></returns>
        public static object ConvertArbitraryCFType(IntPtr Source)
        {
            if (Source == IntPtr.Zero)
            {
                return(null);
            }

            // Convert based on the type of the source object
            uint TypeID = CoreImpl.CFGetTypeID(Source);

            if (TypeID == CoreImpl.CFNumberGetTypeID())
            {
                return(ConvertCFNumber(Source));
            }
            else if (TypeID == CoreImpl.CFStringGetTypeID())
            {
                return(CFStringGetCString(Source));
            }
            else if (TypeID == CoreImpl.CFDictionaryGetTypeID())
            {
                return(ConvertCFDictionaryToDictionary(Source));
            }
            else if (TypeID == CoreImpl.CFBooleanGetTypeID())
            {
                return(Source == kCFBooleanTrue.Handle);
            }

            return(null);
        }