//反序列化 public override void Deserialize(IoBuffer stream) { _value = stream.ReadFloat(); #if SERIALIZE_DEBUG SerializeUtil.AddLog(this); #endif }
//反序列化 public override void Deserialize(IoBuffer stream) { enType t = (enType)stream.ReadByte(); SetType(t); if (_type == enType.Bool) { _value = stream.ReadBool(); } else if (_type == enType.Byte) { _value = stream.ReadByte(); } else if (_type == enType.Short) { _value = stream.ReadInt16(); } else if (_type == enType.Int) { _value = stream.ReadInt32(); } else if (_type == enType.Long) { _value = stream.ReadInt64(); } else if (_type == enType.Float) { _value = stream.ReadFloat(); } else if (_type == enType.Double) { _value = stream.ReadDouble(); } else if (_type == enType.String) { _value = stream.ReadStr(); } else { Debuger.LogError("未知的类型"); } #if SERIALIZE_DEBUG SerializeUtil.AddLog(this); #endif }
public override bool getValue(IoBuffer ioBuffer, System.Type type, byte flag, out object value) { value = null; byte flagType = getFlagTypes(flag); if (flagType != Types.NUMBER) { Debuger.LogError("Types.NUMBER 类型解析出错 {0}", flag); return(false); } // 0000 #000 bool nevigate = ((flag & FLAG_0X08) != 0); // 0000 0### byte signal = getFlagSignal(flag); if (signal == INT32) { int i; if (!readVarInt32(ioBuffer, out i)) { return(false); } if (type == typeof(short)) { value = (short)(nevigate ? -i : i); } else if (type == typeof(byte)) { value = (byte)(nevigate ? -i : i); } else { value = nevigate ? -i : i; } } else if (signal == INT64) { long l; if (!readVarInt64(ioBuffer, out l)) { return(false); } value = nevigate ? -l : l; } else if (signal == FLOAT) { if (ioBuffer.ReadSize < 4) { Debuger.LogError("可读字节长度不足" + 4); return(false); } value = ioBuffer.ReadFloat(); } else if (signal == DOUBLE) { if (ioBuffer.ReadSize < 8) { Debuger.LogError("可读字节长度不足" + 8); return(false); } value = ioBuffer.ReadDouble(); } AddLog(value); return(true); }