Ejemplo n.º 1
0
        // Token: 0x06000015 RID: 21 RVA: 0x0000259C File Offset: 0x0000079C
        private unsafe static object GetNumberFromObject(void *obj)
        {
            CFDictParser.CFNumberType cFNumberType = CFDictParser.CFNumberGetType(obj);
            IntPtr intPtr = Marshal.AllocHGlobal(8);

            CFDictParser.CFNumberGetValue(obj, cFNumberType, intPtr);
            byte[] array = new byte[8];
            Marshal.Copy(intPtr, array, 0, 8);
            Marshal.FreeHGlobal(intPtr);
            switch (cFNumberType)
            {
            case CFDictParser.CFNumberType.kCFNumberSInt16Type:
            {
                object result = BitConverter.ToInt16(array, 0);
                return(result);
            }

            case CFDictParser.CFNumberType.kCFNumberSInt32Type:
            case CFDictParser.CFNumberType.kCFNumberIntType:
            {
                object result = BitConverter.ToInt32(array, 0);
                return(result);
            }

            case CFDictParser.CFNumberType.kCFNumberSInt64Type:
            {
                object result = BitConverter.ToInt64(array, 0);
                return(result);
            }

            case CFDictParser.CFNumberType.kCFNumberFloat32Type:
            case CFDictParser.CFNumberType.kCFNumberFloatType:
            {
                object result = BitConverter.ToSingle(array, 0);
                return(result);
            }

            case CFDictParser.CFNumberType.kCFNumberFloat64Type:
            case CFDictParser.CFNumberType.kCFNumberDoubleType:
            {
                object result = BitConverter.ToDouble(array, 0);
                return(result);
            }
            }
            throw new Exception("CFNumberType not implemented: " + cFNumberType.ToString());
        }