Exemplo n.º 1
0
        public void Read(ref Buffer buffer)
        {
            byte type = buffer.ReadBytesByte();

            Debug.Assert(type == (byte)Global.DataType.DATA_FIELD);

            string sname = buffer.ReadBytesString();

            DataType dataType = (DataType)buffer.ReadBytesByte();

            switch (dataType)
            {
            case DataType.DATA_BOOL: SetData(dataType, buffer.ReadBytesBool(), sname); break;

            case DataType.DATA_CHAR: SetData <byte>(dataType, buffer.ReadBytesByte(), sname); break;

            case DataType.DATA_SHORT: SetData <short>(dataType, buffer.ReadBytesShort(), sname); break;

            case DataType.DATA_INT: SetData <int>(dataType, buffer.ReadBytesInt32(), sname); break;

            case DataType.DATA_LONG_LONG: SetData <Int64> (dataType, (long)buffer.ReadBytesInt64(), sname); break;

            case DataType.DATA_FLOAT: SetData(dataType, buffer.ReadBytesFloat(), sname); break;

            case DataType.DATA_DOUBLE: SetData(dataType, buffer.ReadBytesDouble(), sname); break;

            case DataType.DATA_STRING: SetData(dataType, buffer.ReadBytesString(), sname); break;

            default: throw new ArgumentOutOfRangeException("dataType", "Invalid data type!");
            }
        }
Exemplo n.º 2
0
        public void Read(ref Buffer buffer)
        {
            ushort magic = (ushort)buffer.ReadBytesShort();

            Debug.Assert(magic == Global.MAGIC_NUMBER);

            byte count = buffer.ReadBytesByte();

            List <uint> offsets = new List <uint>();

            for (byte i = 0; i < count; i++)
            {
                offsets.Add((uint)buffer.ReadBytesInt32());
            }

            foreach (uint offs in offsets)
            {
                Debug.Assert(buffer.Position == offs);

                buffer.Position = offs;

                Database db = new Database();

                db.Read(ref buffer);
                AddDatabase(db);
            }
        }
Exemplo n.º 3
0
        public void Read(ref Buffer buffer)
        {
            byte type = buffer.ReadBytesByte();

            Debug.Assert(type == (byte)Global.DataType.DATA_OBJECT);

            name = buffer.ReadBytesString();

            ushort fieldCount = (ushort)buffer.ReadBytesShort();

            for (int i = 0; i < fieldCount; i++)
            {
                Field field = new Field();

                field.Read(ref buffer);
                AddField(field);
            }

            ushort arrayCount = (ushort)buffer.ReadBytesShort();

            for (int i = 0; i < arrayCount; i++)
            {
                Array array = new Array();

                array.Read(ref buffer);
                AddArray(array);
            }
        }
Exemplo n.º 4
0
        public void Read(ref Buffer buffer)
        {
            DataType type = (DataType)buffer.ReadBytesByte();

            Debug.Assert(type == DataType.DATA_ARRAY);

            name = buffer.ReadBytesString();

            dataType = (DataType)buffer.ReadBytesByte();
            count    = (uint)buffer.ReadBytesInt32();

            if (data != null)
            {
                data = null;
            }

            if (dataType != DataType.DATA_STRING)
            {
                data = new byte[count * SizeOf(dataType)];

                System.Array.Copy(buffer.Data, buffer.Position, data, 0, count * SizeOf(dataType));

                buffer.AddOffset(count * SizeOf(dataType));
            }
            else
            {
                uint start = buffer.Position;

                for (uint i = 0; i < count; i++)
                {
                    buffer.ReadBytesString();
                }

                size = buffer.Position - start;

                data = new byte[size];

                System.Array.Copy(buffer.Data, start, data, 0, size);
            }
        }