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!");
            }
        }