public override void Serialize(T obj, Stream stream) { switch (underlyingTypeCode) { case TypeCode.Int64: case TypeCode.UInt64: SimpleStreamUtil.Write(stream, EnumConvert.ToLong(obj)); break; default: SimpleStreamUtil.Write7BitEncodedInt(stream, EnumConvert.ToInt(obj)); break; } }
public override T Deserialize(Stream stream) { switch (underlyingTypeCode) { case TypeCode.Int64: case TypeCode.UInt64: var val64 = SimpleStreamUtil.ReadInt64(stream); return(EnumConvert.ToEnum64 <T>(val64)); default: var val = SimpleStreamUtil.Read7BitEncodedInt(stream); return(EnumConvert.ToEnum32 <T>(val)); } }
public override void Serialize(string obj, Stream stream) { SimpleStreamUtil.Write(stream, obj); }
public override string Deserialize(Stream stream) { return(SimpleStreamUtil.ReadString(stream)); }
public override void Serialize(byte[] obj, Stream stream) { SimpleStreamUtil.Write(stream, obj.Length); SimpleStreamUtil.Write(stream, obj); }
public override byte[] Deserialize(Stream stream) { var count = SimpleStreamUtil.ReadInt(stream); return(SimpleStreamUtil.ReadBytes(stream, count)); }
public override double Deserialize(Stream stream) { return(SimpleStreamUtil.ReadDouble(stream)); }
public override bool Deserialize(Stream stream) { return(SimpleStreamUtil.ReadBoolean(stream)); }
public override byte Deserialize(Stream stream) { return(SimpleStreamUtil.ReadByte(stream)); }
public override float Deserialize(Stream stream) { return(SimpleStreamUtil.ReadSingle(stream)); }
public override int Deserialize(Stream stream) { return(SimpleStreamUtil.ReadInt(stream)); }