public override void Deserialize(byte[] data, ref int offset) { byte numberOfActions = data[offset++]; for (int i = 0; i < numberOfActions; i++) { byte key = data[offset++]; byte type = data[offset++]; switch (type) { case (byte)Types.Integer: int intValue = BitConverter.ToInt32(data, offset); AddInt(key, intValue); offset += sizeof(int); break; case (byte)Types.Byte: byte byteValue = data[offset++]; AddByte(key, byteValue); break; case (byte)Types.ByteArray: int byteArrayLen = BitConverter.ToInt32(data, offset); offset += sizeof(int); byte[] bArray = new byte[byteArrayLen]; for (int indexArray = 0; indexArray < byteArrayLen; indexArray++) { bArray[indexArray] = data[offset + indexArray]; } offset += byteArrayLen; AddByteArray(key, bArray); break; case (byte)Types.String: int strlen = BitConverter.ToInt32(data, offset); offset += sizeof(int); string stringValue = System.Text.Encoding.ASCII.GetString(data, offset, strlen); offset += strlen; AddString(key, stringValue); break; case (byte)Types.FP: FP fpValue = FP.FromRaw(BitConverter.ToInt64(data, offset)); AddFP(key, fpValue); offset += sizeof(long); break; case (byte)Types.TSVector: FP fpValueX = FP.FromRaw(BitConverter.ToInt64(data, offset)); offset += sizeof(long); FP fpValueY = FP.FromRaw(BitConverter.ToInt64(data, offset)); offset += sizeof(long); FP fpValueZ = FP.FromRaw(BitConverter.ToInt64(data, offset)); offset += sizeof(long); AddTSVector(key, new TSVector(fpValueX, fpValueY, fpValueZ)); break; case (byte)Types.TSVector2: FP fpValueX2 = FP.FromRaw(BitConverter.ToInt64(data, offset)); offset += sizeof(long); FP fpValueY2 = FP.FromRaw(BitConverter.ToInt64(data, offset)); offset += sizeof(long); AddTSVector2(key, new TSVector2(fpValueX2, fpValueY2)); break; default: //Not Implemented break; } } }
public FP readFP() { return(FP.FromRaw(readInt64())); }