예제 #1
0
        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;
            }
        }
예제 #2
0
        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));
            }
        }
예제 #3
0
 public override void Serialize(string obj, Stream stream)
 {
     SimpleStreamUtil.Write(stream, obj);
 }
예제 #4
0
 public override string Deserialize(Stream stream)
 {
     return(SimpleStreamUtil.ReadString(stream));
 }
예제 #5
0
 public override void Serialize(byte[] obj, Stream stream)
 {
     SimpleStreamUtil.Write(stream, obj.Length);
     SimpleStreamUtil.Write(stream, obj);
 }
예제 #6
0
        public override byte[] Deserialize(Stream stream)
        {
            var count = SimpleStreamUtil.ReadInt(stream);

            return(SimpleStreamUtil.ReadBytes(stream, count));
        }
예제 #7
0
 public override double Deserialize(Stream stream)
 {
     return(SimpleStreamUtil.ReadDouble(stream));
 }
예제 #8
0
 public override bool Deserialize(Stream stream)
 {
     return(SimpleStreamUtil.ReadBoolean(stream));
 }
예제 #9
0
 public override byte Deserialize(Stream stream)
 {
     return(SimpleStreamUtil.ReadByte(stream));
 }
예제 #10
0
 public override float Deserialize(Stream stream)
 {
     return(SimpleStreamUtil.ReadSingle(stream));
 }
예제 #11
0
 public override int Deserialize(Stream stream)
 {
     return(SimpleStreamUtil.ReadInt(stream));
 }