Files
PURErat-crack-scode/decompiled/PanelPlugins/PureHelper.Client/ProtoBuf.Serializers/ByteSerializer.cs
T
2026-08-27 10:56:38 -06:00

41 lines
840 B
C#

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