Пример #1
0
        static unsafe object Value(DatReader r, char type)
        {
            if (type == 'B')
            {
                return(r.ReadUInt8());
            }
            if (type == 'C')
            {
                return((char)r.ReadUInt16());
            }
            if (type == 'D')
            {
                long tmp = r.ReadInt64(); return(*(double *)(&tmp));
            }
            if (type == 'F')
            {
                int tmp = r.ReadInt32(); return(*(float *)(&tmp));
            }
            if (type == 'I')
            {
                return(r.ReadInt32());
            }
            if (type == 'J')
            {
                return(r.ReadInt64());
            }
            if (type == 'S')
            {
                return(r.ReadInt16());
            }
            if (type == 'Z')
            {
                return(r.ReadUInt8() != 0);
            }
            if (type == 'L')
            {
                return(ReadObject(r));
            }
            if (type == '[')
            {
                return(ReadObject(r));
            }

            throw new InvalidDataException("Invalid value code: " + type);
        }