initial commit

This commit is contained in:
i2p
2026-08-27 10:56:38 -06:00
commit 2e2fbbdb3c
4538 changed files with 820183 additions and 0 deletions
@@ -0,0 +1,40 @@
using System;
using ProtoBuf.Compiler;
using ProtoBuf.Meta;
namespace ProtoBuf.Serializers;
internal sealed class DecimalSerializer : IProtoSerializer
{
private static readonly Type expectedType = typeof(decimal);
public Type ExpectedType => expectedType;
bool IProtoSerializer.RequiresOldValue => false;
bool IProtoSerializer.ReturnsValue => true;
public DecimalSerializer(TypeModel model)
{
}
public object Read(object value, ProtoReader source)
{
return BclHelpers.ReadDecimal(source);
}
public void Write(object value, ProtoWriter dest)
{
BclHelpers.WriteDecimal((decimal)value, dest);
}
void IProtoSerializer.EmitWrite(CompilerContext ctx, Local valueFrom)
{
ctx.EmitWrite(ctx.MapType(typeof(BclHelpers)), "WriteDecimal", valueFrom);
}
void IProtoSerializer.EmitRead(CompilerContext ctx, Local valueFrom)
{
ctx.EmitBasicRead(ctx.MapType(typeof(BclHelpers)), "ReadDecimal", ExpectedType);
}
}