Пример #1
0
        protected static Dictionary <string, object> readData(BinaryReader reader, int count)
        {
            Dictionary <string, object> data = new Dictionary <string, object>();

            for (int i = 0; i < count; i++)
            {
                string       name    = readString(reader);
                DBBinData    type    = (DBBinData)reader.ReadByte();
                DBBinCOMPLEX complex = (DBBinCOMPLEX)reader.ReadByte();
                Object       value   = null;
                switch (complex)
                {
                case DBBinCOMPLEX.None:
                    value = readAttribute(reader, type);
                    break;

                case DBBinCOMPLEX.List:
                    value = readList(reader, type);
                    break;

                case DBBinCOMPLEX.Dict:
                    value = readDict(reader, type);
                    break;
                }
                data.Add(name, value);
            }

            return(data);
        }
Пример #2
0
        protected static Object readList(BinaryReader reader, DBBinData type)
        {
            short count = reader.ReadInt16();

            object[] list = new object[count];
            for (int i = 0; i < count; i++)
            {
                list[i] = readAttribute(reader, type);
            }
            return(list);
        }
Пример #3
0
        protected static Object readDict(BinaryReader reader, DBBinData type)
        {
            short count = reader.ReadInt16();
            Dictionary <string, object> dict = new Dictionary <string, object>(count);

            for (int i = 0; i < count; i++)
            {
                String key   = readString(reader);
                Object value = readAttribute(reader, type);
                dict.Add(key, value);
            }
            return(dict);
        }
Пример #4
0
        protected static object readAttribute(BinaryReader reader, DBBinData type)
        {
            object value = null;

            switch (type)
            {
            case DBBinData.Int:
                value = reader.ReadInt32();
                break;

            case DBBinData.Bool:
                value = reader.ReadBoolean();
                break;

            case DBBinData.Float:
                value = readFloat(reader);
                break;

            case DBBinData.String:
                value = readString(reader);
                break;
            }
            return(value);
        }