Files
2026-06-04 11:42:34 +02:00

288 lines
10 KiB
C#

using System;
using System.Collections.Generic;
namespace Google.Protobuf
{
// Token: 0x02000006 RID: 6
public static class FieldCodec
{
// Token: 0x0600009B RID: 155 RVA: 0x00003C14 File Offset: 0x00001E14
public static FieldCodec<string> ForString(uint tag)
{
return new FieldCodec<string>((CodedInputStream input) => input.ReadString(), delegate(CodedOutputStream output, string value)
{
output.WriteString(value);
}, new Func<string, int>(CodedOutputStream.ComputeStringSize), tag);
}
// Token: 0x0600009C RID: 156 RVA: 0x00003C74 File Offset: 0x00001E74
public static FieldCodec<ByteString> ForBytes(uint tag)
{
return new FieldCodec<ByteString>((CodedInputStream input) => input.ReadBytes(), delegate(CodedOutputStream output, ByteString value)
{
output.WriteBytes(value);
}, new Func<ByteString, int>(CodedOutputStream.ComputeBytesSize), tag);
}
// Token: 0x0600009D RID: 157 RVA: 0x00003CD4 File Offset: 0x00001ED4
public static FieldCodec<bool> ForBool(uint tag)
{
return new FieldCodec<bool>((CodedInputStream input) => input.ReadBool(), delegate(CodedOutputStream output, bool value)
{
output.WriteBool(value);
}, new Func<bool, int>(CodedOutputStream.ComputeBoolSize), tag);
}
// Token: 0x0600009E RID: 158 RVA: 0x00003D34 File Offset: 0x00001F34
public static FieldCodec<int> ForInt32(uint tag)
{
return new FieldCodec<int>((CodedInputStream input) => input.ReadInt32(), delegate(CodedOutputStream output, int value)
{
output.WriteInt32(value);
}, new Func<int, int>(CodedOutputStream.ComputeInt32Size), tag);
}
// Token: 0x0600009F RID: 159 RVA: 0x00003D94 File Offset: 0x00001F94
public static FieldCodec<int> ForSInt32(uint tag)
{
return new FieldCodec<int>((CodedInputStream input) => input.ReadSInt32(), delegate(CodedOutputStream output, int value)
{
output.WriteSInt32(value);
}, new Func<int, int>(CodedOutputStream.ComputeSInt32Size), tag);
}
// Token: 0x060000A0 RID: 160 RVA: 0x00003DF4 File Offset: 0x00001FF4
public static FieldCodec<uint> ForFixed32(uint tag)
{
return new FieldCodec<uint>((CodedInputStream input) => input.ReadFixed32(), delegate(CodedOutputStream output, uint value)
{
output.WriteFixed32(value);
}, 4, tag);
}
// Token: 0x060000A1 RID: 161 RVA: 0x00003E48 File Offset: 0x00002048
public static FieldCodec<int> ForSFixed32(uint tag)
{
return new FieldCodec<int>((CodedInputStream input) => input.ReadSFixed32(), delegate(CodedOutputStream output, int value)
{
output.WriteSFixed32(value);
}, 4, tag);
}
// Token: 0x060000A2 RID: 162 RVA: 0x00003E9C File Offset: 0x0000209C
public static FieldCodec<uint> ForUInt32(uint tag)
{
return new FieldCodec<uint>((CodedInputStream input) => input.ReadUInt32(), delegate(CodedOutputStream output, uint value)
{
output.WriteUInt32(value);
}, new Func<uint, int>(CodedOutputStream.ComputeUInt32Size), tag);
}
// Token: 0x060000A3 RID: 163 RVA: 0x00003EFC File Offset: 0x000020FC
public static FieldCodec<long> ForInt64(uint tag)
{
return new FieldCodec<long>((CodedInputStream input) => input.ReadInt64(), delegate(CodedOutputStream output, long value)
{
output.WriteInt64(value);
}, new Func<long, int>(CodedOutputStream.ComputeInt64Size), tag);
}
// Token: 0x060000A4 RID: 164 RVA: 0x00003F5C File Offset: 0x0000215C
public static FieldCodec<long> ForSInt64(uint tag)
{
return new FieldCodec<long>((CodedInputStream input) => input.ReadSInt64(), delegate(CodedOutputStream output, long value)
{
output.WriteSInt64(value);
}, new Func<long, int>(CodedOutputStream.ComputeSInt64Size), tag);
}
// Token: 0x060000A5 RID: 165 RVA: 0x00003FBC File Offset: 0x000021BC
public static FieldCodec<ulong> ForFixed64(uint tag)
{
return new FieldCodec<ulong>((CodedInputStream input) => input.ReadFixed64(), delegate(CodedOutputStream output, ulong value)
{
output.WriteFixed64(value);
}, 8, tag);
}
// Token: 0x060000A6 RID: 166 RVA: 0x00004010 File Offset: 0x00002210
public static FieldCodec<long> ForSFixed64(uint tag)
{
return new FieldCodec<long>((CodedInputStream input) => input.ReadSFixed64(), delegate(CodedOutputStream output, long value)
{
output.WriteSFixed64(value);
}, 8, tag);
}
// Token: 0x060000A7 RID: 167 RVA: 0x00004064 File Offset: 0x00002264
public static FieldCodec<ulong> ForUInt64(uint tag)
{
return new FieldCodec<ulong>((CodedInputStream input) => input.ReadUInt64(), delegate(CodedOutputStream output, ulong value)
{
output.WriteUInt64(value);
}, new Func<ulong, int>(CodedOutputStream.ComputeUInt64Size), tag);
}
// Token: 0x060000A8 RID: 168 RVA: 0x000040C4 File Offset: 0x000022C4
public static FieldCodec<float> ForFloat(uint tag)
{
return new FieldCodec<float>((CodedInputStream input) => input.ReadFloat(), delegate(CodedOutputStream output, float value)
{
output.WriteFloat(value);
}, new Func<float, int>(CodedOutputStream.ComputeFloatSize), tag);
}
// Token: 0x060000A9 RID: 169 RVA: 0x00004124 File Offset: 0x00002324
public static FieldCodec<double> ForDouble(uint tag)
{
return new FieldCodec<double>((CodedInputStream input) => input.ReadDouble(), delegate(CodedOutputStream output, double value)
{
output.WriteDouble(value);
}, new Func<double, int>(CodedOutputStream.ComputeDoubleSize), tag);
}
// Token: 0x060000AA RID: 170 RVA: 0x00004184 File Offset: 0x00002384
public static FieldCodec<T> ForEnum<T>(uint tag, Func<T, int> toInt32, Func<int, T> fromInt32)
{
return new FieldCodec<T>((CodedInputStream input) => fromInt32(input.ReadEnum()), delegate(CodedOutputStream output, T value)
{
output.WriteEnum(toInt32(value));
}, (T value) => CodedOutputStream.ComputeEnumSize(toInt32(value)), tag);
}
// Token: 0x060000AB RID: 171 RVA: 0x000041D0 File Offset: 0x000023D0
public static FieldCodec<T> ForMessage<T>(uint tag, MessageParser<T> parser) where T : IMessage<T>
{
return new FieldCodec<T>(delegate(CodedInputStream input)
{
T t = parser.CreateTemplate();
input.ReadMessage(t);
return t;
}, delegate(CodedOutputStream output, T value)
{
output.WriteMessage(value);
}, (T message) => CodedOutputStream.ComputeMessageSize(message), tag);
}
// Token: 0x060000AC RID: 172 RVA: 0x00004238 File Offset: 0x00002438
public static FieldCodec<T> ForClassWrapper<T>(uint tag) where T : class
{
FieldCodec<T> nestedCodec = FieldCodec.WrapperCodecs.GetCodec<T>();
return new FieldCodec<T>((CodedInputStream input) => FieldCodec.WrapperCodecs.Read<T>(input, nestedCodec), delegate(CodedOutputStream output, T value)
{
FieldCodec.WrapperCodecs.Write<T>(output, value, nestedCodec);
}, (T value) => FieldCodec.WrapperCodecs.CalculateSize<T>(value, nestedCodec), tag, default(T));
}
// Token: 0x060000AD RID: 173 RVA: 0x0000428C File Offset: 0x0000248C
public static FieldCodec<T?> ForStructWrapper<T>(uint tag) where T : struct
{
FieldCodec<T> nestedCodec = FieldCodec.WrapperCodecs.GetCodec<T>();
return new FieldCodec<T?>((CodedInputStream input) => new T?(FieldCodec.WrapperCodecs.Read<T>(input, nestedCodec)), delegate(CodedOutputStream output, T? value)
{
FieldCodec.WrapperCodecs.Write<T>(output, value.Value, nestedCodec);
}, delegate(T? value)
{
if (value != null)
{
return FieldCodec.WrapperCodecs.CalculateSize<T>(value.Value, nestedCodec);
}
return 0;
}, tag, null);
}
// Token: 0x02000075 RID: 117
private static class WrapperCodecs
{
// Token: 0x06000672 RID: 1650 RVA: 0x00016278 File Offset: 0x00014478
internal static FieldCodec<T> GetCodec<T>()
{
object obj;
if (!FieldCodec.WrapperCodecs.Codecs.TryGetValue(typeof(T), out obj))
{
throw new InvalidOperationException("Invalid type argument requested for wrapper codec: " + typeof(T));
}
return (FieldCodec<T>)obj;
}
// Token: 0x06000673 RID: 1651 RVA: 0x000162C0 File Offset: 0x000144C0
internal static T Read<T>(CodedInputStream input, FieldCodec<T> codec)
{
int num = input.ReadLength();
int num2 = input.PushLimit(num);
T t = codec.DefaultValue;
uint num3;
while ((num3 = input.ReadTag()) != 0U)
{
if (num3 == codec.Tag)
{
t = codec.Read(input);
}
else
{
input.SkipLastField();
}
}
input.CheckReadEndOfStreamTag();
input.PopLimit(num2);
return t;
}
// Token: 0x06000674 RID: 1652 RVA: 0x00016316 File Offset: 0x00014516
internal static void Write<T>(CodedOutputStream output, T value, FieldCodec<T> codec)
{
output.WriteLength(codec.CalculateSizeWithTag(value));
codec.WriteTagAndValue(output, value);
}
// Token: 0x06000675 RID: 1653 RVA: 0x00016330 File Offset: 0x00014530
internal static int CalculateSize<T>(T value, FieldCodec<T> codec)
{
int num = codec.CalculateSizeWithTag(value);
return CodedOutputStream.ComputeLengthSize(num) + num;
}
// Token: 0x0400026E RID: 622
private static readonly Dictionary<Type, object> Codecs = new Dictionary<Type, object>
{
{
typeof(bool),
FieldCodec.ForBool(WireFormat.MakeTag(1, WireFormat.WireType.Varint))
},
{
typeof(int),
FieldCodec.ForInt32(WireFormat.MakeTag(1, WireFormat.WireType.Varint))
},
{
typeof(long),
FieldCodec.ForInt64(WireFormat.MakeTag(1, WireFormat.WireType.Varint))
},
{
typeof(uint),
FieldCodec.ForUInt32(WireFormat.MakeTag(1, WireFormat.WireType.Varint))
},
{
typeof(ulong),
FieldCodec.ForUInt64(WireFormat.MakeTag(1, WireFormat.WireType.Varint))
},
{
typeof(float),
FieldCodec.ForFloat(WireFormat.MakeTag(1, WireFormat.WireType.Fixed32))
},
{
typeof(double),
FieldCodec.ForDouble(WireFormat.MakeTag(1, WireFormat.WireType.Fixed64))
},
{
typeof(string),
FieldCodec.ForString(WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited))
},
{
typeof(ByteString),
FieldCodec.ForBytes(WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited))
}
};
}
}
}