public override object OnValue(Type type) { if (type == typeof(bool)) { return(Stream.ReadUInt8() == 1); } else if (type == typeof(char)) { return((char)Stream.ReadUInt8()); } else if (type == typeof(short)) { return(IntegerHelper.DecodeZigzag(Stream.ReadVarUInt16())); } else if (type == typeof(int)) { return(IntegerHelper.DecodeZigzag(Stream.ReadVarUInt32())); } else if (type == typeof(Int64)) { return(IntegerHelper.DecodeZigzag(Stream.ReadVarUInt64())); } else if (type == typeof(byte)) { return(Stream.ReadUInt8()); } else if (type == typeof(ushort)) { return(Stream.ReadVarUInt16()); } else if (type == typeof(uint)) { return(Stream.ReadVarUInt32()); } else if (type == typeof(UInt64)) { return(Stream.ReadVarUInt64()); } else if (type == typeof(float)) { return(Stream.ReadFloat()); } else if (type == typeof(double)) { return(Stream.ReadDouble()); } else { if (type.IsEnum) { return(Stream.ReadVarUInt32()); } else { Logger.ErrorLine("Invalid value type:{0}", type); } } return(null); }