41 lines
846 B
C#
41 lines
846 B
C#
using System;
|
|
using ProtoBuf.Compiler;
|
|
using ProtoBuf.Meta;
|
|
|
|
namespace ProtoBuf.Serializers;
|
|
|
|
internal sealed class Int64Serializer : IProtoSerializer
|
|
{
|
|
private static readonly Type expectedType = typeof(long);
|
|
|
|
public Type ExpectedType => expectedType;
|
|
|
|
bool IProtoSerializer.RequiresOldValue => false;
|
|
|
|
bool IProtoSerializer.ReturnsValue => true;
|
|
|
|
public Int64Serializer(TypeModel model)
|
|
{
|
|
}
|
|
|
|
public object Read(object value, ProtoReader source)
|
|
{
|
|
return source.ReadInt64();
|
|
}
|
|
|
|
public void Write(object value, ProtoWriter dest)
|
|
{
|
|
ProtoWriter.WriteInt64((long)value, dest);
|
|
}
|
|
|
|
void IProtoSerializer.EmitWrite(CompilerContext ctx, Local valueFrom)
|
|
{
|
|
ctx.EmitBasicWrite("WriteInt64", valueFrom);
|
|
}
|
|
|
|
void IProtoSerializer.EmitRead(CompilerContext ctx, Local valueFrom)
|
|
{
|
|
ctx.EmitBasicRead("ReadInt64", ExpectedType);
|
|
}
|
|
}
|