using System; using ProtoBuf.Compiler; using ProtoBuf.Meta; namespace ProtoBuf.Serializers; internal sealed class DoubleSerializer : IProtoSerializer { private static readonly Type expectedType = typeof(double); public Type ExpectedType => expectedType; bool IProtoSerializer.RequiresOldValue => false; bool IProtoSerializer.ReturnsValue => true; public DoubleSerializer(TypeModel model) { } public object Read(object value, ProtoReader source) { return source.ReadDouble(); } public void Write(object value, ProtoWriter dest) { ProtoWriter.WriteDouble((double)value, dest); } void IProtoSerializer.EmitWrite(CompilerContext ctx, Local valueFrom) { ctx.EmitBasicWrite("WriteDouble", valueFrom); } void IProtoSerializer.EmitRead(CompilerContext ctx, Local valueFrom) { ctx.EmitBasicRead("ReadDouble", ExpectedType); } }