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