From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../ProtoBuf/Serializers/ArrayDecorator.cs | 172 ++++++++ .../ProtoBuf/Serializers/ArrayDecorator.cs.meta | 12 + .../ProtoBuf/Serializers/BlobSerializer.cs | 51 +++ .../ProtoBuf/Serializers/BlobSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/BooleanSerializer.cs | 49 +++ .../ProtoBuf/Serializers/BooleanSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/ByteSerializer.cs | 49 +++ .../ProtoBuf/Serializers/ByteSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/CharSerializer.cs | 33 ++ .../ProtoBuf/Serializers/CharSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/DateTimeSerializer.cs | 49 +++ .../Serializers/DateTimeSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/DecimalSerializer.cs | 49 +++ .../ProtoBuf/Serializers/DecimalSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/DefaultValueDecorator.cs | 64 +++ .../Serializers/DefaultValueDecorator.cs.meta | 12 + .../ProtoBuf/Serializers/DoubleSerializer.cs | 49 +++ .../ProtoBuf/Serializers/DoubleSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/EnumSerializer.cs | 213 ++++++++++ .../ProtoBuf/Serializers/EnumSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/FieldDecorator.cs | 67 ++++ .../ProtoBuf/Serializers/FieldDecorator.cs.meta | 12 + .../ProtoBuf/Serializers/GuidSerializer.cs | 49 +++ .../ProtoBuf/Serializers/GuidSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/IProtoSerializer.cs | 17 + .../ProtoBuf/Serializers/IProtoSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/IProtoTypeSerializer.cs | 16 + .../Serializers/IProtoTypeSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/ISerializerProxy.cs | 9 + .../ProtoBuf/Serializers/ISerializerProxy.cs.meta | 12 + .../Serializers/ImmutableCollectionDecorator.cs | 252 ++++++++++++ .../ImmutableCollectionDecorator.cs.meta | 12 + .../ProtoBuf/Serializers/Int16Serializer.cs | 49 +++ .../ProtoBuf/Serializers/Int16Serializer.cs.meta | 12 + .../ProtoBuf/Serializers/Int32Serializer.cs | 49 +++ .../ProtoBuf/Serializers/Int32Serializer.cs.meta | 12 + .../ProtoBuf/Serializers/Int64Serializer.cs | 49 +++ .../ProtoBuf/Serializers/Int64Serializer.cs.meta | 12 + .../ProtoBuf/Serializers/ListDecorator.cs | 365 +++++++++++++++++ .../ProtoBuf/Serializers/ListDecorator.cs.meta | 12 + .../Serializers/MemberSpecifiedDecorator.cs | 68 ++++ .../Serializers/MemberSpecifiedDecorator.cs.meta | 12 + .../ProtoBuf/Serializers/NetObjectSerializer.cs | 56 +++ .../Serializers/NetObjectSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/NullDecorator.cs | 89 +++++ .../ProtoBuf/Serializers/NullDecorator.cs.meta | 12 + .../ProtoBuf/Serializers/ParseableSerializer.cs | 91 +++++ .../Serializers/ParseableSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/PropertyDecorator.cs | 143 +++++++ .../ProtoBuf/Serializers/PropertyDecorator.cs.meta | 12 + .../ProtoBuf/Serializers/ProtoDecoratorBase.cs | 30 ++ .../Serializers/ProtoDecoratorBase.cs.meta | 12 + .../ProtoBuf/Serializers/SByteSerializer.cs | 49 +++ .../ProtoBuf/Serializers/SByteSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/SingleSerializer.cs | 49 +++ .../ProtoBuf/Serializers/SingleSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/StringSerializer.cs | 49 +++ .../ProtoBuf/Serializers/StringSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/SubItemSerializer.cs | 96 +++++ .../ProtoBuf/Serializers/SubItemSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/SurrogateSerializer.cs | 154 +++++++ .../Serializers/SurrogateSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/SystemTypeSerializer.cs | 49 +++ .../Serializers/SystemTypeSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/TagDecorator.cs | 105 +++++ .../ProtoBuf/Serializers/TagDecorator.cs.meta | 12 + .../ProtoBuf/Serializers/TimeSpanSerializer.cs | 49 +++ .../Serializers/TimeSpanSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/TupleSerializer.cs | 211 ++++++++++ .../ProtoBuf/Serializers/TupleSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/TypeSerializer.cs | 445 +++++++++++++++++++++ .../ProtoBuf/Serializers/TypeSerializer.cs.meta | 12 + .../ProtoBuf/Serializers/UInt16Serializer.cs | 49 +++ .../ProtoBuf/Serializers/UInt16Serializer.cs.meta | 12 + .../ProtoBuf/Serializers/UInt32Serializer.cs | 49 +++ .../ProtoBuf/Serializers/UInt32Serializer.cs.meta | 12 + .../ProtoBuf/Serializers/UInt64Serializer.cs | 49 +++ .../ProtoBuf/Serializers/UInt64Serializer.cs.meta | 12 + .../ProtoBuf/Serializers/UriDecorator.cs | 50 +++ .../ProtoBuf/Serializers/UriDecorator.cs.meta | 12 + 80 files changed, 4110 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ArrayDecorator.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ArrayDecorator.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/BlobSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/BlobSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/BooleanSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/BooleanSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ByteSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ByteSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/CharSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/CharSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DateTimeSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DateTimeSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DecimalSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DecimalSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DefaultValueDecorator.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DefaultValueDecorator.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DoubleSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DoubleSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/EnumSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/EnumSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/FieldDecorator.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/FieldDecorator.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/GuidSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/GuidSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/IProtoSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/IProtoSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/IProtoTypeSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/IProtoTypeSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ISerializerProxy.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ISerializerProxy.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ImmutableCollectionDecorator.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ImmutableCollectionDecorator.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int16Serializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int16Serializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int32Serializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int32Serializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int64Serializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int64Serializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ListDecorator.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ListDecorator.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/MemberSpecifiedDecorator.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/MemberSpecifiedDecorator.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/NetObjectSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/NetObjectSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/NullDecorator.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/NullDecorator.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ParseableSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ParseableSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/PropertyDecorator.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/PropertyDecorator.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ProtoDecoratorBase.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ProtoDecoratorBase.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SByteSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SByteSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SingleSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SingleSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/StringSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/StringSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SubItemSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SubItemSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SurrogateSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SurrogateSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SystemTypeSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SystemTypeSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TagDecorator.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TagDecorator.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TimeSpanSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TimeSpanSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TupleSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TupleSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TypeSerializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TypeSerializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt16Serializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt16Serializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt32Serializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt32Serializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt64Serializer.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt64Serializer.cs.meta create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UriDecorator.cs create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UriDecorator.cs.meta (limited to 'Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers') diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ArrayDecorator.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ArrayDecorator.cs new file mode 100644 index 00000000..9634fafb --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ArrayDecorator.cs @@ -0,0 +1,172 @@ +using System; +using System.Collections; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class ArrayDecorator : ProtoDecoratorBase + { + public override Type ExpectedType + { + get + { + return this.arrayType; + } + } + + public override bool RequiresOldValue + { + get + { + return this.AppendToCollection; + } + } + + public override bool ReturnsValue + { + get + { + return true; + } + } + + private bool AppendToCollection + { + get + { + return (this.options & 2) == 0; + } + } + + private bool SupportNull + { + get + { + return (this.options & 4) > 0; + } + } + + private readonly int fieldNumber; + + private const byte OPTIONS_WritePacked = 1; + + private const byte OPTIONS_OverwriteList = 2; + + private const byte OPTIONS_SupportNull = 4; + + private readonly byte options; + + private readonly WireType packedWireType; + + private readonly Type arrayType; + + private readonly Type itemType; + + public ArrayDecorator(TypeModel model, IProtoSerializer tail, int fieldNumber, bool writePacked, WireType packedWireType, Type arrayType, bool overwriteList, bool supportNull) : base(tail) + { + Helpers.DebugAssert(arrayType != null, "arrayType should be non-null"); + Helpers.DebugAssert(arrayType.IsArray && arrayType.GetArrayRank() == 1, "should be single-dimension array; " + arrayType.FullName); + this.itemType = arrayType.GetElementType(); + Type type = supportNull ? this.itemType : (Helpers.GetUnderlyingType(this.itemType) ?? this.itemType); + Helpers.DebugAssert(type == this.Tail.ExpectedType, "invalid tail"); + Helpers.DebugAssert(this.Tail.ExpectedType != model.MapType(typeof(byte)), "Should have used BlobSerializer"); + bool flag = (writePacked || packedWireType != WireType.None) && fieldNumber <= 0; + if (flag) + { + throw new ArgumentOutOfRangeException("fieldNumber"); + } + bool flag2 = !ListDecorator.CanPack(packedWireType); + if (flag2) + { + if (writePacked) + { + throw new InvalidOperationException("Only simple data-types can use packed encoding"); + } + packedWireType = WireType.None; + } + this.fieldNumber = fieldNumber; + this.packedWireType = packedWireType; + if (writePacked) + { + this.options |= 1; + } + if (overwriteList) + { + this.options |= 2; + } + if (supportNull) + { + this.options |= 4; + } + this.arrayType = arrayType; + } + + public override void Write(object value, ProtoWriter dest) + { + IList list = (IList)value; + int count = list.Count; + bool flag = (this.options & 1) > 0; + bool flag2 = flag; + SubItemToken token; + if (flag2) + { + ProtoWriter.WriteFieldHeader(this.fieldNumber, WireType.String, dest); + token = ProtoWriter.StartSubItem(value, dest); + ProtoWriter.SetPackedField(this.fieldNumber, dest); + } + else + { + token = default(SubItemToken); + } + bool flag3 = !this.SupportNull; + for (int i = 0; i < count; i++) + { + object obj = list[i]; + bool flag4 = flag3 && obj == null; + if (flag4) + { + throw new NullReferenceException(); + } + this.Tail.Write(obj, dest); + } + bool flag5 = flag; + if (flag5) + { + ProtoWriter.EndSubItem(token, dest); + } + } + + public override object Read(object value, ProtoReader source) + { + int field = source.FieldNumber; + BasicList basicList = new BasicList(); + bool flag = this.packedWireType != WireType.None && source.WireType == WireType.String; + if (flag) + { + SubItemToken token = ProtoReader.StartSubItem(source); + while (ProtoReader.HasSubValue(this.packedWireType, source)) + { + basicList.Add(this.Tail.Read(null, source)); + } + ProtoReader.EndSubItem(token, source); + } + else + { + do + { + basicList.Add(this.Tail.Read(null, source)); + } + while (source.TryReadFieldHeader(field)); + } + int num = this.AppendToCollection ? ((value == null) ? 0 : ((Array)value).Length) : 0; + Array array = Array.CreateInstance(this.itemType, num + basicList.Count); + bool flag2 = num != 0; + if (flag2) + { + ((Array)value).CopyTo(array, 0); + } + basicList.CopyTo(array, num); + return array; + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ArrayDecorator.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ArrayDecorator.cs.meta new file mode 100644 index 00000000..4118f71e --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ArrayDecorator.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: cfb085ae7c0ba154c8a66f748221079a +timeCreated: 1611404582 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/BlobSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/BlobSerializer.cs new file mode 100644 index 00000000..b249fe6c --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/BlobSerializer.cs @@ -0,0 +1,51 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class BlobSerializer : IProtoSerializer + { + public Type ExpectedType + { + get + { + return BlobSerializer.expectedType; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return !this.overwriteList; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private static readonly Type expectedType = typeof(byte[]); + + private readonly bool overwriteList; + + public BlobSerializer(TypeModel model, bool overwriteList) + { + this.overwriteList = overwriteList; + } + + public object Read(object value, ProtoReader source) + { + return ProtoReader.AppendBytes(this.overwriteList ? null : ((byte[])value), source); + } + + public void Write(object value, ProtoWriter dest) + { + ProtoWriter.WriteBytes((byte[])value, dest); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/BlobSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/BlobSerializer.cs.meta new file mode 100644 index 00000000..b521ab6e --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/BlobSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 017be01ffdc177044beb3e9b4ecba537 +timeCreated: 1611402953 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/BooleanSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/BooleanSerializer.cs new file mode 100644 index 00000000..93f5b63c --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/BooleanSerializer.cs @@ -0,0 +1,49 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class BooleanSerializer : IProtoSerializer + { + public Type ExpectedType + { + get + { + return BooleanSerializer.expectedType; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return false; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private static readonly Type expectedType = typeof(bool); + + public BooleanSerializer(TypeModel model) + { + } + + public void Write(object value, ProtoWriter dest) + { + ProtoWriter.WriteBoolean((bool)value, dest); + } + + public object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + return source.ReadBoolean(); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/BooleanSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/BooleanSerializer.cs.meta new file mode 100644 index 00000000..f809b897 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/BooleanSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 649d4d3ef34c60e48be87bc1648abf7b +timeCreated: 1611403848 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ByteSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ByteSerializer.cs new file mode 100644 index 00000000..5699af9a --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ByteSerializer.cs @@ -0,0 +1,49 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class ByteSerializer : IProtoSerializer + { + public Type ExpectedType + { + get + { + return ByteSerializer.expectedType; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return false; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private static readonly Type expectedType = typeof(byte); + + public ByteSerializer(TypeModel model) + { + } + + public void Write(object value, ProtoWriter dest) + { + ProtoWriter.WriteByte((byte)value, dest); + } + + public object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + return source.ReadByte(); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ByteSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ByteSerializer.cs.meta new file mode 100644 index 00000000..730f66c9 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ByteSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c9a349c90850d3b479ef0b631a202e04 +timeCreated: 1611404539 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/CharSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/CharSerializer.cs new file mode 100644 index 00000000..f2a9867a --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/CharSerializer.cs @@ -0,0 +1,33 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class CharSerializer : UInt16Serializer + { + public override Type ExpectedType + { + get + { + return CharSerializer.expectedType; + } + } + + private static readonly Type expectedType = typeof(char); + + public CharSerializer(TypeModel model) : base(model) + { + } + + public override void Write(object value, ProtoWriter dest) + { + ProtoWriter.WriteUInt16((ushort)((char)value), dest); + } + + public override object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + return (char)source.ReadUInt16(); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/CharSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/CharSerializer.cs.meta new file mode 100644 index 00000000..79753d83 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/CharSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8a2711f42e4488d43a40e0ae660ff0fc +timeCreated: 1611404090 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DateTimeSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DateTimeSerializer.cs new file mode 100644 index 00000000..47895725 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DateTimeSerializer.cs @@ -0,0 +1,49 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class DateTimeSerializer : IProtoSerializer + { + public Type ExpectedType + { + get + { + return DateTimeSerializer.expectedType; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return false; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private static readonly Type expectedType = typeof(DateTime); + + public DateTimeSerializer(TypeModel model) + { + } + + public object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + return BclHelpers.ReadDateTime(source); + } + + public void Write(object value, ProtoWriter dest) + { + BclHelpers.WriteDateTime((DateTime)value, dest); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DateTimeSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DateTimeSerializer.cs.meta new file mode 100644 index 00000000..706f3b5e --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DateTimeSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 364d58f505fc4e64b8e0810ce3ab8b2f +timeCreated: 1611403562 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DecimalSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DecimalSerializer.cs new file mode 100644 index 00000000..fd6c3ceb --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DecimalSerializer.cs @@ -0,0 +1,49 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class DecimalSerializer : IProtoSerializer + { + public Type ExpectedType + { + get + { + return DecimalSerializer.expectedType; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return false; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private static readonly Type expectedType = typeof(decimal); + + public DecimalSerializer(TypeModel model) + { + } + + public object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + return BclHelpers.ReadDecimal(source); + } + + public void Write(object value, ProtoWriter dest) + { + BclHelpers.WriteDecimal((decimal)value, dest); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DecimalSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DecimalSerializer.cs.meta new file mode 100644 index 00000000..f224e2b1 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DecimalSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 644402a116273d14d938548871680373 +timeCreated: 1611403847 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DefaultValueDecorator.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DefaultValueDecorator.cs new file mode 100644 index 00000000..cbbe2821 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DefaultValueDecorator.cs @@ -0,0 +1,64 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class DefaultValueDecorator : ProtoDecoratorBase + { + public override Type ExpectedType + { + get + { + return this.Tail.ExpectedType; + } + } + + public override bool RequiresOldValue + { + get + { + return this.Tail.RequiresOldValue; + } + } + + public override bool ReturnsValue + { + get + { + return this.Tail.ReturnsValue; + } + } + + private readonly object defaultValue; + + public DefaultValueDecorator(TypeModel model, object defaultValue, IProtoSerializer tail) : base(tail) + { + bool flag = defaultValue == null; + if (flag) + { + throw new ArgumentNullException("defaultValue"); + } + Type type = model.MapType(defaultValue.GetType()); + bool flag2 = type != tail.ExpectedType; + if (flag2) + { + throw new ArgumentException("Default value is of incorrect type", "defaultValue"); + } + this.defaultValue = defaultValue; + } + + public override void Write(object value, ProtoWriter dest) + { + bool flag = !object.Equals(value, this.defaultValue); + if (flag) + { + this.Tail.Write(value, dest); + } + } + + public override object Read(object value, ProtoReader source) + { + return this.Tail.Read(value, source); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DefaultValueDecorator.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DefaultValueDecorator.cs.meta new file mode 100644 index 00000000..d7ed0ccf --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DefaultValueDecorator.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c318dd759689fa24fa949fbac543b491 +timeCreated: 1611404496 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DoubleSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DoubleSerializer.cs new file mode 100644 index 00000000..fa250b9b --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DoubleSerializer.cs @@ -0,0 +1,49 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class DoubleSerializer : IProtoSerializer + { + public Type ExpectedType + { + get + { + return DoubleSerializer.expectedType; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return false; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private static readonly Type expectedType = typeof(double); + + public DoubleSerializer(TypeModel model) + { + } + + public object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + return source.ReadDouble(); + } + + public void Write(object value, ProtoWriter dest) + { + ProtoWriter.WriteDouble((double)value, dest); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DoubleSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DoubleSerializer.cs.meta new file mode 100644 index 00000000..14abd32a --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/DoubleSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: be222b20076978a42b534a41d4fffc33 +timeCreated: 1611404458 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/EnumSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/EnumSerializer.cs new file mode 100644 index 00000000..3136c29e --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/EnumSerializer.cs @@ -0,0 +1,213 @@ +using System; +using XUtliPoolLib; + +namespace ProtoBuf.Serializers +{ + internal sealed class EnumSerializer : IProtoSerializer + { + public Type ExpectedType + { + get + { + return this.enumType; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return false; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private readonly Type enumType; + + private readonly EnumSerializer.EnumPair[] map; + + public struct EnumPair + { + public readonly object RawValue; + + public readonly Enum TypedValue; + + public readonly int WireValue; + + public EnumPair(int wireValue, object raw, Type type) + { + this.WireValue = wireValue; + this.RawValue = raw; + this.TypedValue = (Enum)Enum.ToObject(type, raw); + } + } + + public EnumSerializer(Type enumType, EnumSerializer.EnumPair[] map) + { + bool flag = enumType == null; + if (flag) + { + throw new ArgumentNullException("enumType"); + } + this.enumType = enumType; + this.map = map; + bool flag2 = map != null; + if (flag2) + { + for (int i = 1; i < map.Length; i++) + { + for (int j = 0; j < i; j++) + { + bool flag3 = map[i].WireValue == map[j].WireValue && !object.Equals(map[i].RawValue, map[j].RawValue); + if (flag3) + { + throw new ProtoException("Multiple enums with wire-value " + map[i].WireValue.ToString()); + } + bool flag4 = object.Equals(map[i].RawValue, map[j].RawValue) && map[i].WireValue != map[j].WireValue; + if (flag4) + { + throw new ProtoException("Multiple enums with deserialized-value " + map[i].RawValue); + } + } + } + } + } + + private ProtoTypeCode GetTypeCode() + { + Type underlyingType = Helpers.GetUnderlyingType(this.enumType); + bool flag = underlyingType == null; + if (flag) + { + underlyingType = this.enumType; + } + return Helpers.GetTypeCode(underlyingType); + } + + private int EnumToWire(object value) + { + int result; + switch (this.GetTypeCode()) + { + case ProtoTypeCode.SByte: + result = (int)((sbyte)value); + break; + case ProtoTypeCode.Byte: + result = (int)((byte)value); + break; + case ProtoTypeCode.Int16: + result = (int)((short)value); + break; + case ProtoTypeCode.UInt16: + result = (int)((ushort)value); + break; + case ProtoTypeCode.Int32: + result = (int)value; + break; + case ProtoTypeCode.UInt32: + result = (int)((uint)value); + break; + case ProtoTypeCode.Int64: + result = (int)((long)value); + break; + case ProtoTypeCode.UInt64: + result = (int)((ulong)value); + break; + default: + throw new InvalidOperationException(); + } + return result; + } + + private object WireToEnum(int value) + { + object result; + switch (this.GetTypeCode()) + { + case ProtoTypeCode.SByte: + result = Enum.ToObject(this.enumType, (sbyte)value); + break; + case ProtoTypeCode.Byte: + result = Enum.ToObject(this.enumType, (byte)value); + break; + case ProtoTypeCode.Int16: + result = Enum.ToObject(this.enumType, (short)value); + break; + case ProtoTypeCode.UInt16: + result = Enum.ToObject(this.enumType, (ushort)value); + break; + case ProtoTypeCode.Int32: + result = Enum.ToObject(this.enumType, value); + break; + case ProtoTypeCode.UInt32: + result = Enum.ToObject(this.enumType, (uint)value); + break; + case ProtoTypeCode.Int64: + result = Enum.ToObject(this.enumType, (long)value); + break; + case ProtoTypeCode.UInt64: + result = Enum.ToObject(this.enumType, (ulong)((long)value)); + break; + default: + throw new InvalidOperationException(); + } + return result; + } + + public object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + int num = source.ReadInt32(); + bool flag = this.map == null; + object result; + if (flag) + { + result = this.WireToEnum(num); + } + else + { + for (int i = 0; i < this.map.Length; i++) + { + bool flag2 = this.map[i].WireValue == num; + if (flag2) + { + return this.map[i].TypedValue; + } + } + XSingleton.singleton.AddWarningLog("Warning: No ", (this.ExpectedType == null) ? "" : this.ExpectedType.FullName, " enum is mapped to the wire-value ", num.ToString(), null, null); + result = this.WireToEnum(num); + } + return result; + } + + public void Write(object value, ProtoWriter dest) + { + bool flag = this.map == null; + if (flag) + { + ProtoWriter.WriteInt32(this.EnumToWire(value), dest); + } + else + { + for (int i = 0; i < this.map.Length; i++) + { + bool flag2 = object.Equals(this.map[i].TypedValue, value); + if (flag2) + { + ProtoWriter.WriteInt32(this.map[i].WireValue, dest); + return; + } + } + XSingleton.singleton.AddErrorLog("Warning: No wire-value is mapped to the enum ", (value == null) ? "" : (value.GetType().FullName + "." + value.ToString()), " at position ", (dest == null) ? "unknown" : ProtoWriter.GetPosition(dest).ToString(), null, null); + ProtoWriter.WriteInt32(this.EnumToWire(value), dest); + } + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/EnumSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/EnumSerializer.cs.meta new file mode 100644 index 00000000..b7d8f3ff --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/EnumSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5f5b7489e6b0ddc4b93c4825e7a746fe +timeCreated: 1611403811 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/FieldDecorator.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/FieldDecorator.cs new file mode 100644 index 00000000..144ab3e7 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/FieldDecorator.cs @@ -0,0 +1,67 @@ +using System; +using System.Reflection; + +namespace ProtoBuf.Serializers +{ + internal sealed class FieldDecorator : ProtoDecoratorBase + { + public override Type ExpectedType + { + get + { + return this.forType; + } + } + + public override bool RequiresOldValue + { + get + { + return true; + } + } + + public override bool ReturnsValue + { + get + { + return false; + } + } + + private readonly FieldInfo field; + + private readonly Type forType; + + public FieldDecorator(Type forType, FieldInfo field, IProtoSerializer tail) : base(tail) + { + Helpers.DebugAssert(forType != null); + Helpers.DebugAssert(field != null); + this.forType = forType; + this.field = field; + } + + public override void Write(object value, ProtoWriter dest) + { + Helpers.DebugAssert(value != null); + value = this.field.GetValue(value); + bool flag = value != null; + if (flag) + { + this.Tail.Write(value, dest); + } + } + + public override object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value != null); + object obj = this.Tail.Read(this.Tail.RequiresOldValue ? this.field.GetValue(value) : null, source); + bool flag = obj != null; + if (flag) + { + this.field.SetValue(value, obj); + } + return null; + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/FieldDecorator.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/FieldDecorator.cs.meta new file mode 100644 index 00000000..b0e12b26 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/FieldDecorator.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7652c542da7cdc84ea87f1238de8651a +timeCreated: 1611403949 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/GuidSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/GuidSerializer.cs new file mode 100644 index 00000000..f9edaec9 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/GuidSerializer.cs @@ -0,0 +1,49 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class GuidSerializer : IProtoSerializer + { + public Type ExpectedType + { + get + { + return GuidSerializer.expectedType; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return false; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private static readonly Type expectedType = typeof(Guid); + + public GuidSerializer(TypeModel model) + { + } + + public void Write(object value, ProtoWriter dest) + { + BclHelpers.WriteGuid((Guid)value, dest); + } + + public object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + return BclHelpers.ReadGuid(source); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/GuidSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/GuidSerializer.cs.meta new file mode 100644 index 00000000..7bdf5b62 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/GuidSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1743c869ef5abe840a34aeb5767cd253 +timeCreated: 1611403292 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/IProtoSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/IProtoSerializer.cs new file mode 100644 index 00000000..401b758a --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/IProtoSerializer.cs @@ -0,0 +1,17 @@ +using System; + +namespace ProtoBuf.Serializers +{ + internal interface IProtoSerializer + { + Type ExpectedType { get; } + + bool RequiresOldValue { get; } + + bool ReturnsValue { get; } + + void Write(object value, ProtoWriter dest); + + object Read(object value, ProtoReader source); + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/IProtoSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/IProtoSerializer.cs.meta new file mode 100644 index 00000000..1fc41e76 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/IProtoSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: afc4abbab9743b74480e53f6e061e1c4 +timeCreated: 1611404347 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/IProtoTypeSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/IProtoTypeSerializer.cs new file mode 100644 index 00000000..d45e8049 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/IProtoTypeSerializer.cs @@ -0,0 +1,16 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal interface IProtoTypeSerializer : IProtoSerializer + { + bool HasCallbacks(TypeModel.CallbackType callbackType); + + bool CanCreateInstance(); + + object CreateInstance(ProtoReader source); + + void Callback(object value, TypeModel.CallbackType callbackType, SerializationContext context); + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/IProtoTypeSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/IProtoTypeSerializer.cs.meta new file mode 100644 index 00000000..0f9231d0 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/IProtoTypeSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 12c7d0a3501f09743a248ea724ff6427 +timeCreated: 1611403243 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ISerializerProxy.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ISerializerProxy.cs new file mode 100644 index 00000000..7105976b --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ISerializerProxy.cs @@ -0,0 +1,9 @@ +using System; + +namespace ProtoBuf.Serializers +{ + internal interface ISerializerProxy + { + IProtoSerializer Serializer { get; } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ISerializerProxy.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ISerializerProxy.cs.meta new file mode 100644 index 00000000..86848b70 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ISerializerProxy.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 19beab5bc626c734aafa122334e6aee2 +timeCreated: 1611403304 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ImmutableCollectionDecorator.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ImmutableCollectionDecorator.cs new file mode 100644 index 00000000..8133228d --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ImmutableCollectionDecorator.cs @@ -0,0 +1,252 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class ImmutableCollectionDecorator : ListDecorator + { + protected override bool RequireAdd + { + get + { + return false; + } + } + + private readonly MethodInfo builderFactory; + + private readonly MethodInfo add; + + private readonly MethodInfo addRange; + + private readonly MethodInfo finish; + + private static Type ResolveIReadOnlyCollection(Type declaredType, Type t) + { + foreach (Type type in declaredType.GetInterfaces()) + { + bool flag = type.IsGenericType && type.Name.StartsWith("IReadOnlyCollection`"); + if (flag) + { + bool flag2 = t != null; + if (flag2) + { + Type[] genericArguments = type.GetGenericArguments(); + bool flag3 = genericArguments.Length != 1 && genericArguments[0] != t; + if (flag3) + { + goto IL_68; + } + } + return type; + } + IL_68:; + } + return null; + } + + internal static bool IdentifyImmutable(TypeModel model, Type declaredType, out MethodInfo builderFactory, out MethodInfo add, out MethodInfo addRange, out MethodInfo finish) + { + MethodInfo methodInfo; + finish = (methodInfo = null); + addRange = (methodInfo = methodInfo); + add = (methodInfo = methodInfo); + builderFactory = methodInfo; + bool flag = model == null || declaredType == null; + bool result; + if (flag) + { + result = false; + } + else + { + bool flag2 = !declaredType.IsGenericType; + if (flag2) + { + result = false; + } + else + { + Type[] genericArguments = declaredType.GetGenericArguments(); + int num = genericArguments.Length; + Type[] array; + if (num != 1) + { + if (num != 2) + { + return false; + } + Type type = model.MapType(typeof(KeyValuePair<, >)); + bool flag3 = type == null; + if (flag3) + { + return false; + } + type = type.MakeGenericType(genericArguments); + array = new Type[] + { + type + }; + } + else + { + array = genericArguments; + } + bool flag4 = ImmutableCollectionDecorator.ResolveIReadOnlyCollection(declaredType, null) == null; + if (flag4) + { + result = false; + } + else + { + string text = declaredType.Name; + int num2 = text.IndexOf('`'); + bool flag5 = num2 <= 0; + if (flag5) + { + result = false; + } + else + { + text = (declaredType.IsInterface ? text.Substring(1, num2 - 1) : text.Substring(0, num2)); + Type type2 = model.GetType(declaredType.Namespace + "." + text, declaredType.Assembly); + bool flag6 = type2 == null && text == "ImmutableSet"; + if (flag6) + { + type2 = model.GetType(declaredType.Namespace + ".ImmutableHashSet", declaredType.Assembly); + } + bool flag7 = type2 == null; + if (flag7) + { + result = false; + } + else + { + foreach (MethodInfo methodInfo2 in type2.GetMethods()) + { + bool flag8 = !methodInfo2.IsStatic || methodInfo2.Name != "CreateBuilder" || !methodInfo2.IsGenericMethodDefinition || methodInfo2.GetParameters().Length != 0 || methodInfo2.GetGenericArguments().Length != genericArguments.Length; + if (!flag8) + { + builderFactory = methodInfo2.MakeGenericMethod(genericArguments); + break; + } + } + Type type3 = model.MapType(typeof(void)); + bool flag9 = builderFactory == null || builderFactory.ReturnType == null || builderFactory.ReturnType == type3; + if (flag9) + { + result = false; + } + else + { + add = Helpers.GetInstanceMethod(builderFactory.ReturnType, "Add", array); + bool flag10 = add == null; + if (flag10) + { + result = false; + } + else + { + finish = Helpers.GetInstanceMethod(builderFactory.ReturnType, "ToImmutable", Helpers.EmptyTypes); + bool flag11 = finish == null || finish.ReturnType == null || finish.ReturnType == type3; + if (flag11) + { + result = false; + } + else + { + bool flag12 = finish.ReturnType != declaredType && !Helpers.IsAssignableFrom(declaredType, finish.ReturnType); + if (flag12) + { + result = false; + } + else + { + addRange = Helpers.GetInstanceMethod(builderFactory.ReturnType, "AddRange", new Type[] + { + declaredType + }); + bool flag13 = addRange == null; + if (flag13) + { + Type type4 = model.MapType(typeof(IEnumerable<>), false); + bool flag14 = type4 != null; + if (flag14) + { + addRange = Helpers.GetInstanceMethod(builderFactory.ReturnType, "AddRange", new Type[] + { + type4.MakeGenericType(array) + }); + } + } + result = true; + } + } + } + } + } + } + } + } + } + return result; + } + + internal ImmutableCollectionDecorator(TypeModel model, Type declaredType, Type concreteType, IProtoSerializer tail, int fieldNumber, bool writePacked, WireType packedWireType, bool returnList, bool overwriteList, bool supportNull, MethodInfo builderFactory, MethodInfo add, MethodInfo addRange, MethodInfo finish) : base(model, declaredType, concreteType, tail, fieldNumber, writePacked, packedWireType, returnList, overwriteList, supportNull) + { + this.builderFactory = builderFactory; + this.add = add; + this.addRange = addRange; + this.finish = finish; + } + + public override object Read(object value, ProtoReader source) + { + object obj = this.builderFactory.Invoke(null, null); + int fieldNumber = source.FieldNumber; + object[] s_argsRead = ProtoDecoratorBase.s_argsRead; + bool flag = base.AppendToCollection && value != null && ((IList)value).Count != 0; + if (flag) + { + bool flag2 = this.addRange != null; + if (flag2) + { + s_argsRead[0] = value; + this.addRange.Invoke(obj, s_argsRead); + } + else + { + foreach (object obj2 in ((IList)value)) + { + s_argsRead[0] = obj2; + this.add.Invoke(obj, s_argsRead); + } + } + } + bool flag3 = this.packedWireType != WireType.None && source.WireType == WireType.String; + if (flag3) + { + SubItemToken token = ProtoReader.StartSubItem(source); + while (ProtoReader.HasSubValue(this.packedWireType, source)) + { + s_argsRead[0] = this.Tail.Read(null, source); + this.add.Invoke(obj, s_argsRead); + } + ProtoReader.EndSubItem(token, source); + } + else + { + do + { + s_argsRead[0] = this.Tail.Read(null, source); + this.add.Invoke(obj, s_argsRead); + } + while (source.TryReadFieldHeader(fieldNumber)); + } + return this.finish.Invoke(obj, null); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ImmutableCollectionDecorator.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ImmutableCollectionDecorator.cs.meta new file mode 100644 index 00000000..8ffa65f1 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ImmutableCollectionDecorator.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 995822048d3cf254a8a90d30634d77bd +timeCreated: 1611404195 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int16Serializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int16Serializer.cs new file mode 100644 index 00000000..e50ab1a5 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int16Serializer.cs @@ -0,0 +1,49 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class Int16Serializer : IProtoSerializer + { + public Type ExpectedType + { + get + { + return Int16Serializer.expectedType; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return false; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private static readonly Type expectedType = typeof(short); + + public Int16Serializer(TypeModel model) + { + } + + public object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + return source.ReadInt16(); + } + + public void Write(object value, ProtoWriter dest) + { + ProtoWriter.WriteInt16((short)value, dest); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int16Serializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int16Serializer.cs.meta new file mode 100644 index 00000000..d67d3dbc --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int16Serializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a35395277c429fe4e81a544136a3b71f +timeCreated: 1611404260 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int32Serializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int32Serializer.cs new file mode 100644 index 00000000..29c21112 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int32Serializer.cs @@ -0,0 +1,49 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class Int32Serializer : IProtoSerializer + { + public Type ExpectedType + { + get + { + return Int32Serializer.expectedType; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return false; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private static readonly Type expectedType = typeof(int); + + public Int32Serializer(TypeModel model) + { + } + + public object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + return source.ReadInt32(); + } + + public void Write(object value, ProtoWriter dest) + { + ProtoWriter.WriteInt32((int)value, dest); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int32Serializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int32Serializer.cs.meta new file mode 100644 index 00000000..c765da66 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int32Serializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 02408c964247cdc48af98e06a8bc7fbd +timeCreated: 1611402956 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int64Serializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int64Serializer.cs new file mode 100644 index 00000000..857ac8f7 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int64Serializer.cs @@ -0,0 +1,49 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class Int64Serializer : IProtoSerializer + { + public Type ExpectedType + { + get + { + return Int64Serializer.expectedType; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return false; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private static readonly Type expectedType = typeof(long); + + public Int64Serializer(TypeModel model) + { + } + + public object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + return source.ReadInt64(); + } + + public void Write(object value, ProtoWriter dest) + { + ProtoWriter.WriteInt64((long)value, dest); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int64Serializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int64Serializer.cs.meta new file mode 100644 index 00000000..a75538f7 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/Int64Serializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b883828ac17beb84db2bbd7bc703d530 +timeCreated: 1611404405 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ListDecorator.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ListDecorator.cs new file mode 100644 index 00000000..2c03de30 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ListDecorator.cs @@ -0,0 +1,365 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal class ListDecorator : ProtoDecoratorBase + { + private bool IsList + { + get + { + return (this.options & 1) > 0; + } + } + + private bool SuppressIList + { + get + { + return (this.options & 2) > 0; + } + } + + private bool WritePacked + { + get + { + return (this.options & 4) > 0; + } + } + + private bool SupportNull + { + get + { + return (this.options & 32) > 0; + } + } + + private bool ReturnList + { + get + { + return (this.options & 8) > 0; + } + } + + protected virtual bool RequireAdd + { + get + { + return true; + } + } + + public override Type ExpectedType + { + get + { + return this.declaredType; + } + } + + public override bool RequiresOldValue + { + get + { + return this.AppendToCollection; + } + } + + public override bool ReturnsValue + { + get + { + return this.ReturnList; + } + } + + protected bool AppendToCollection + { + get + { + return (this.options & 16) == 0; + } + } + + private readonly byte options; + + private const byte OPTIONS_IsList = 1; + + private const byte OPTIONS_SuppressIList = 2; + + private const byte OPTIONS_WritePacked = 4; + + private const byte OPTIONS_ReturnList = 8; + + private const byte OPTIONS_OverwriteList = 16; + + private const byte OPTIONS_SupportNull = 32; + + private readonly Type declaredType; + + private readonly Type concreteType; + + private readonly MethodInfo add; + + private readonly int fieldNumber; + + protected readonly WireType packedWireType; + + private static readonly Type ienumeratorType = typeof(IEnumerator); + + private static readonly Type ienumerableType = typeof(IEnumerable); + + internal static bool CanPack(WireType wireType) + { + return wireType <= WireType.Fixed64 || wireType == WireType.Fixed32 || wireType == WireType.SignedVariant; + } + + internal static ListDecorator Create(TypeModel model, Type declaredType, Type concreteType, IProtoSerializer tail, int fieldNumber, bool writePacked, WireType packedWireType, bool returnList, bool overwriteList, bool supportNull) + { + MethodInfo builderFactory = null; + MethodInfo methodInfo = null; + MethodInfo addRange = null; + MethodInfo finish = null; + bool flag = returnList && ImmutableCollectionDecorator.IdentifyImmutable(model, declaredType, out builderFactory, out methodInfo, out addRange, out finish); + ListDecorator result; + if (flag) + { + result = new ImmutableCollectionDecorator(model, declaredType, concreteType, tail, fieldNumber, writePacked, packedWireType, returnList, overwriteList, supportNull, builderFactory, methodInfo, addRange, finish); + } + else + { + result = new ListDecorator(model, declaredType, concreteType, tail, fieldNumber, writePacked, packedWireType, returnList, overwriteList, supportNull); + } + return result; + } + + protected ListDecorator(TypeModel model, Type declaredType, Type concreteType, IProtoSerializer tail, int fieldNumber, bool writePacked, WireType packedWireType, bool returnList, bool overwriteList, bool supportNull) : base(tail) + { + if (returnList) + { + this.options |= 8; + } + if (overwriteList) + { + this.options |= 16; + } + if (supportNull) + { + this.options |= 32; + } + bool flag = (writePacked || packedWireType != WireType.None) && fieldNumber <= 0; + if (flag) + { + throw new ArgumentOutOfRangeException("fieldNumber"); + } + bool flag2 = !ListDecorator.CanPack(packedWireType); + if (flag2) + { + if (writePacked) + { + throw new InvalidOperationException("Only simple data-types can use packed encoding"); + } + packedWireType = WireType.None; + } + this.fieldNumber = fieldNumber; + if (writePacked) + { + this.options |= 4; + } + this.packedWireType = packedWireType; + bool flag3 = declaredType == null; + if (flag3) + { + throw new ArgumentNullException("declaredType"); + } + bool isArray = declaredType.IsArray; + if (isArray) + { + throw new ArgumentException("Cannot treat arrays as lists", "declaredType"); + } + this.declaredType = declaredType; + this.concreteType = concreteType; + bool requireAdd = this.RequireAdd; + if (requireAdd) + { + bool flag4; + this.add = TypeModel.ResolveListAdd(model, declaredType, tail.ExpectedType, out flag4); + bool flag5 = flag4; + if (flag5) + { + this.options |= 1; + string fullName = declaredType.FullName; + bool flag6 = fullName != null && fullName.StartsWith("System.Data.Linq.EntitySet`1[["); + if (flag6) + { + this.options |= 2; + } + } + bool flag7 = this.add == null; + if (flag7) + { + throw new InvalidOperationException("Unable to resolve a suitable Add method for " + declaredType.FullName); + } + } + } + + protected MethodInfo GetEnumeratorInfo(TypeModel model, out MethodInfo moveNext, out MethodInfo current) + { + Type type = null; + Type expectedType = this.ExpectedType; + MethodInfo instanceMethod = Helpers.GetInstanceMethod(expectedType, "GetEnumerator", null); + Type expectedType2 = this.Tail.ExpectedType; + bool flag = instanceMethod != null; + if (flag) + { + Type returnType = instanceMethod.ReturnType; + Type type2 = returnType; + moveNext = Helpers.GetInstanceMethod(type2, "MoveNext", null); + PropertyInfo property = Helpers.GetProperty(type2, "Current", false); + current = ((property == null) ? null : Helpers.GetGetMethod(property, false, false)); + bool flag2 = moveNext == null && model.MapType(ListDecorator.ienumeratorType).IsAssignableFrom(type2); + if (flag2) + { + moveNext = Helpers.GetInstanceMethod(model.MapType(ListDecorator.ienumeratorType), "MoveNext", null); + } + bool flag3 = moveNext != null && moveNext.ReturnType == model.MapType(typeof(bool)) && current != null && current.ReturnType == expectedType2; + if (flag3) + { + return instanceMethod; + } + MethodInfo methodInfo; + current = (methodInfo = null); + moveNext = methodInfo; + } + Type type3 = model.MapType(typeof(IEnumerable<>), false); + bool flag4 = type3 != null; + if (flag4) + { + type3 = type3.MakeGenericType(new Type[] + { + expectedType2 + }); + type = type3; + } + bool flag5 = type != null && type.IsAssignableFrom(expectedType); + MethodInfo result; + if (flag5) + { + instanceMethod = Helpers.GetInstanceMethod(type, "GetEnumerator"); + Type returnType = instanceMethod.ReturnType; + Type type2 = returnType; + moveNext = Helpers.GetInstanceMethod(model.MapType(ListDecorator.ienumeratorType), "MoveNext"); + current = Helpers.GetGetMethod(Helpers.GetProperty(type2, "Current", false), false, false); + result = instanceMethod; + } + else + { + type = model.MapType(ListDecorator.ienumerableType); + instanceMethod = Helpers.GetInstanceMethod(type, "GetEnumerator"); + Type returnType = instanceMethod.ReturnType; + Type type2 = returnType; + moveNext = Helpers.GetInstanceMethod(type2, "MoveNext"); + current = Helpers.GetGetMethod(Helpers.GetProperty(type2, "Current", false), false, false); + result = instanceMethod; + } + return result; + } + + public override void Write(object value, ProtoWriter dest) + { + bool writePacked = this.WritePacked; + bool flag = writePacked; + SubItemToken token; + if (flag) + { + ProtoWriter.WriteFieldHeader(this.fieldNumber, WireType.String, dest); + token = ProtoWriter.StartSubItem(value, dest); + ProtoWriter.SetPackedField(this.fieldNumber, dest); + } + else + { + token = default(SubItemToken); + } + bool flag2 = !this.SupportNull; + foreach (object obj in ((IEnumerable)value)) + { + bool flag3 = flag2 && obj == null; + if (flag3) + { + throw new NullReferenceException(); + } + this.Tail.Write(obj, dest); + } + bool flag4 = writePacked; + if (flag4) + { + ProtoWriter.EndSubItem(token, dest); + } + } + + public override object Read(object value, ProtoReader source) + { + int field = source.FieldNumber; + object obj = value; + bool flag = value == null; + if (flag) + { + value = Activator.CreateInstance(this.concreteType); + } + bool flag2 = this.IsList && !this.SuppressIList; + bool flag3 = this.packedWireType != WireType.None && source.WireType == WireType.String; + if (flag3) + { + SubItemToken token = ProtoReader.StartSubItem(source); + bool flag4 = flag2; + if (flag4) + { + IList list = (IList)value; + while (ProtoReader.HasSubValue(this.packedWireType, source)) + { + list.Add(this.Tail.Read(null, source)); + } + } + else + { + while (ProtoReader.HasSubValue(this.packedWireType, source)) + { + ProtoDecoratorBase.s_argsRead[0] = this.Tail.Read(null, source); + this.add.Invoke(value, ProtoDecoratorBase.s_argsRead); + } + } + ProtoReader.EndSubItem(token, source); + } + else + { + bool flag5 = flag2; + if (flag5) + { + IList list2 = (IList)value; + do + { + list2.Add(this.Tail.Read(null, source)); + } + while (source.TryReadFieldHeader(field)); + } + else + { + do + { + ProtoDecoratorBase.s_argsRead[0] = this.Tail.Read(null, source); + this.add.Invoke(value, ProtoDecoratorBase.s_argsRead); + } + while (source.TryReadFieldHeader(field)); + } + } + return (obj == value) ? null : value; + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ListDecorator.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ListDecorator.cs.meta new file mode 100644 index 00000000..3c06cf2d --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ListDecorator.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fefcfc6e8a6b98341bf92b7df50d27d2 +timeCreated: 1611404944 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/MemberSpecifiedDecorator.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/MemberSpecifiedDecorator.cs new file mode 100644 index 00000000..95683855 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/MemberSpecifiedDecorator.cs @@ -0,0 +1,68 @@ +using System; +using System.Reflection; + +namespace ProtoBuf.Serializers +{ + internal sealed class MemberSpecifiedDecorator : ProtoDecoratorBase + { + public override Type ExpectedType + { + get + { + return this.Tail.ExpectedType; + } + } + + public override bool RequiresOldValue + { + get + { + return this.Tail.RequiresOldValue; + } + } + + public override bool ReturnsValue + { + get + { + return this.Tail.ReturnsValue; + } + } + + private readonly MethodInfo getSpecified; + + private readonly MethodInfo setSpecified; + + public MemberSpecifiedDecorator(MethodInfo getSpecified, MethodInfo setSpecified, IProtoSerializer tail) : base(tail) + { + bool flag = getSpecified == null && setSpecified == null; + if (flag) + { + throw new InvalidOperationException(); + } + this.getSpecified = getSpecified; + this.setSpecified = setSpecified; + } + + public override void Write(object value, ProtoWriter dest) + { + bool flag = this.getSpecified == null || (bool)this.getSpecified.Invoke(value, null); + if (flag) + { + this.Tail.Write(value, dest); + } + } + + public override object Read(object value, ProtoReader source) + { + object result = this.Tail.Read(value, source); + ProtoDecoratorBase.s_argsRead[0] = true; + bool flag = this.setSpecified != null; + if (flag) + { + this.setSpecified.Invoke(value, ProtoDecoratorBase.s_argsRead); + } + return result; + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/MemberSpecifiedDecorator.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/MemberSpecifiedDecorator.cs.meta new file mode 100644 index 00000000..793dcf44 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/MemberSpecifiedDecorator.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 739518db68917a34e836154cb2eaf459 +timeCreated: 1611403941 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/NetObjectSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/NetObjectSerializer.cs new file mode 100644 index 00000000..6dd8be72 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/NetObjectSerializer.cs @@ -0,0 +1,56 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class NetObjectSerializer : IProtoSerializer + { + public Type ExpectedType + { + get + { + return this.type; + } + } + + public bool ReturnsValue + { + get + { + return true; + } + } + + public bool RequiresOldValue + { + get + { + return true; + } + } + + private readonly int key; + + private readonly Type type; + + private readonly BclHelpers.NetObjectOptions options; + + public NetObjectSerializer(TypeModel model, Type type, int key, BclHelpers.NetObjectOptions options) + { + bool flag = (options & BclHelpers.NetObjectOptions.DynamicType) > BclHelpers.NetObjectOptions.None; + this.key = (flag ? -1 : key); + this.type = (flag ? model.MapType(typeof(object)) : type); + this.options = options; + } + + public object Read(object value, ProtoReader source) + { + return BclHelpers.ReadNetObject(value, source, this.key, (this.type == typeof(object)) ? null : this.type, this.options); + } + + public void Write(object value, ProtoWriter dest) + { + BclHelpers.WriteNetObject(value, dest, this.key, this.options); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/NetObjectSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/NetObjectSerializer.cs.meta new file mode 100644 index 00000000..1ab011bb --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/NetObjectSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a98a338097dc0e846bbe30b6f334caf6 +timeCreated: 1611404299 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/NullDecorator.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/NullDecorator.cs new file mode 100644 index 00000000..2285d847 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/NullDecorator.cs @@ -0,0 +1,89 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class NullDecorator : ProtoDecoratorBase + { + public override Type ExpectedType + { + get + { + return this.expectedType; + } + } + + public override bool ReturnsValue + { + get + { + return true; + } + } + + public override bool RequiresOldValue + { + get + { + return true; + } + } + + private readonly Type expectedType; + + public const int Tag = 1; + + public NullDecorator(TypeModel model, IProtoSerializer tail) : base(tail) + { + bool flag = !tail.ReturnsValue; + if (flag) + { + throw new NotSupportedException("NullDecorator only supports implementations that return values"); + } + Type type = tail.ExpectedType; + bool flag2 = Helpers.IsValueType(type); + if (flag2) + { + this.expectedType = model.MapType(typeof(Nullable<>)).MakeGenericType(new Type[] + { + type + }); + } + else + { + this.expectedType = type; + } + } + + public override object Read(object value, ProtoReader source) + { + SubItemToken token = ProtoReader.StartSubItem(source); + int num; + while ((num = source.ReadFieldHeader()) > 0) + { + bool flag = num == 1; + if (flag) + { + value = this.Tail.Read(value, source); + } + else + { + source.SkipField(); + } + } + ProtoReader.EndSubItem(token, source); + return value; + } + + public override void Write(object value, ProtoWriter dest) + { + SubItemToken token = ProtoWriter.StartSubItem(null, dest); + bool flag = value != null; + if (flag) + { + this.Tail.Write(value, dest); + } + ProtoWriter.EndSubItem(token, dest); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/NullDecorator.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/NullDecorator.cs.meta new file mode 100644 index 00000000..fb5b1c05 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/NullDecorator.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 05d6503399b3fa748a1d9a82686028a3 +timeCreated: 1611402964 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ParseableSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ParseableSerializer.cs new file mode 100644 index 00000000..8cc1b68d --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ParseableSerializer.cs @@ -0,0 +1,91 @@ +using System; +using System.Reflection; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class ParseableSerializer : IProtoSerializer + { + public Type ExpectedType + { + get + { + return this.parse.DeclaringType; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return false; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private readonly MethodInfo parse; + + public static ParseableSerializer TryCreate(Type type, TypeModel model) + { + bool flag = type == null; + if (flag) + { + throw new ArgumentNullException("type"); + } + MethodInfo method = type.GetMethod("Parse", BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public, null, new Type[] + { + model.MapType(typeof(string)) + }, null); + bool flag2 = method != null && method.ReturnType == type; + ParseableSerializer result; + if (flag2) + { + bool flag3 = Helpers.IsValueType(type); + if (flag3) + { + MethodInfo customToString = ParseableSerializer.GetCustomToString(type); + bool flag4 = customToString == null || customToString.ReturnType != model.MapType(typeof(string)); + if (flag4) + { + return null; + } + } + result = new ParseableSerializer(method); + } + else + { + result = null; + } + return result; + } + + private static MethodInfo GetCustomToString(Type type) + { + return type.GetMethod("ToString", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public, null, Helpers.EmptyTypes, null); + } + + private ParseableSerializer(MethodInfo parse) + { + this.parse = parse; + } + + public object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + ProtoDecoratorBase.s_argsRead[0] = source.ReadString(); + return this.parse.Invoke(null, ProtoDecoratorBase.s_argsRead); + } + + public void Write(object value, ProtoWriter dest) + { + ProtoWriter.WriteString(value.ToString(), dest); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ParseableSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ParseableSerializer.cs.meta new file mode 100644 index 00000000..7b87947e --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ParseableSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 833aecc4d9c5272499fdfa8e8acfca59 +timeCreated: 1611404043 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/PropertyDecorator.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/PropertyDecorator.cs new file mode 100644 index 00000000..4240d53d --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/PropertyDecorator.cs @@ -0,0 +1,143 @@ +using System; +using System.Reflection; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class PropertyDecorator : ProtoDecoratorBase + { + public override Type ExpectedType + { + get + { + return this.forType; + } + } + + public override bool RequiresOldValue + { + get + { + return true; + } + } + + public override bool ReturnsValue + { + get + { + return false; + } + } + + private readonly PropertyInfo property; + + private readonly Type forType; + + private readonly bool readOptionsWriteValue; + + private readonly MethodInfo shadowSetter; + + public PropertyDecorator(TypeModel model, Type forType, PropertyInfo property, IProtoSerializer tail) : base(tail) + { + Helpers.DebugAssert(forType != null); + Helpers.DebugAssert(property != null); + this.forType = forType; + this.property = property; + PropertyDecorator.SanityCheck(model, property, tail, out this.readOptionsWriteValue, true, true); + this.shadowSetter = PropertyDecorator.GetShadowSetter(model, property); + } + + private static void SanityCheck(TypeModel model, PropertyInfo property, IProtoSerializer tail, out bool writeValue, bool nonPublic, bool allowInternal) + { + bool flag = property == null; + if (flag) + { + throw new ArgumentNullException("property"); + } + writeValue = (tail.ReturnsValue && (PropertyDecorator.GetShadowSetter(model, property) != null || (property.CanWrite && Helpers.GetSetMethod(property, nonPublic, allowInternal) != null))); + bool flag2 = !property.CanRead || Helpers.GetGetMethod(property, nonPublic, allowInternal) == null; + if (flag2) + { + throw new InvalidOperationException("Cannot serialize property without a get accessor"); + } + bool flag3 = !writeValue && (!tail.RequiresOldValue || Helpers.IsValueType(tail.ExpectedType)); + if (flag3) + { + throw new InvalidOperationException("Cannot apply changes to property " + property.DeclaringType.FullName + "." + property.Name); + } + } + + private static MethodInfo GetShadowSetter(TypeModel model, PropertyInfo property) + { + Type reflectedType = property.ReflectedType; + ProtoDecoratorBase.s_propertyType[0] = property.PropertyType; + MethodInfo instanceMethod = Helpers.GetInstanceMethod(reflectedType, "Set" + property.Name, ProtoDecoratorBase.s_propertyType); + bool flag = instanceMethod == null || !instanceMethod.IsPublic || instanceMethod.ReturnType != model.MapType(typeof(void)); + MethodInfo result; + if (flag) + { + result = null; + } + else + { + result = instanceMethod; + } + return result; + } + + public override void Write(object value, ProtoWriter dest) + { + Helpers.DebugAssert(value != null); + value = this.property.GetValue(value, null); + bool flag = value != null; + if (flag) + { + this.Tail.Write(value, dest); + } + } + + public override object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value != null); + object value2 = this.Tail.RequiresOldValue ? this.property.GetValue(value, null) : null; + object obj = this.Tail.Read(value2, source); + bool flag = this.readOptionsWriteValue && obj != null; + if (flag) + { + bool flag2 = this.shadowSetter == null; + if (flag2) + { + this.property.SetValue(value, obj, null); + } + else + { + ProtoDecoratorBase.s_argsRead[0] = obj; + this.shadowSetter.Invoke(value, ProtoDecoratorBase.s_argsRead); + } + } + return null; + } + + internal static bool CanWrite(TypeModel model, MemberInfo member) + { + bool flag = member == null; + if (flag) + { + throw new ArgumentNullException("member"); + } + PropertyInfo propertyInfo = member as PropertyInfo; + bool flag2 = propertyInfo != null; + bool result; + if (flag2) + { + result = (propertyInfo.CanWrite || PropertyDecorator.GetShadowSetter(model, propertyInfo) != null); + } + else + { + result = (member is FieldInfo); + } + return result; + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/PropertyDecorator.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/PropertyDecorator.cs.meta new file mode 100644 index 00000000..edd7c89e --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/PropertyDecorator.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f0600dad016715249ba5a8362c4e93b4 +timeCreated: 1611404831 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ProtoDecoratorBase.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ProtoDecoratorBase.cs new file mode 100644 index 00000000..e8195611 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ProtoDecoratorBase.cs @@ -0,0 +1,30 @@ +using System; + +namespace ProtoBuf.Serializers +{ + internal abstract class ProtoDecoratorBase : IProtoSerializer + { + public abstract Type ExpectedType { get; } + + public abstract bool ReturnsValue { get; } + + public abstract bool RequiresOldValue { get; } + + protected readonly IProtoSerializer Tail; + + public static Type[] s_propertyType = new Type[1]; + + public static object[] s_argsRead = new object[1]; + + public static object[] s_argsWrite = new object[1]; + + protected ProtoDecoratorBase(IProtoSerializer tail) + { + this.Tail = tail; + } + + public abstract void Write(object value, ProtoWriter dest); + + public abstract object Read(object value, ProtoReader source); + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ProtoDecoratorBase.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ProtoDecoratorBase.cs.meta new file mode 100644 index 00000000..0783e64b --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/ProtoDecoratorBase.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7f721c5867de15248b13f8d3c9abb615 +timeCreated: 1611404030 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SByteSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SByteSerializer.cs new file mode 100644 index 00000000..04880c52 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SByteSerializer.cs @@ -0,0 +1,49 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class SByteSerializer : IProtoSerializer + { + public Type ExpectedType + { + get + { + return SByteSerializer.expectedType; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return false; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private static readonly Type expectedType = typeof(sbyte); + + public SByteSerializer(TypeModel model) + { + } + + public object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + return source.ReadSByte(); + } + + public void Write(object value, ProtoWriter dest) + { + ProtoWriter.WriteSByte((sbyte)value, dest); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SByteSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SByteSerializer.cs.meta new file mode 100644 index 00000000..bb30cebe --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SByteSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c62250c7286c2d045814ce99fe761bee +timeCreated: 1611404508 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SingleSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SingleSerializer.cs new file mode 100644 index 00000000..1b49bf8a --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SingleSerializer.cs @@ -0,0 +1,49 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class SingleSerializer : IProtoSerializer + { + public Type ExpectedType + { + get + { + return SingleSerializer.expectedType; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return false; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private static readonly Type expectedType = typeof(float); + + public SingleSerializer(TypeModel model) + { + } + + public object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + return source.ReadSingle(); + } + + public void Write(object value, ProtoWriter dest) + { + ProtoWriter.WriteSingle((float)value, dest); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SingleSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SingleSerializer.cs.meta new file mode 100644 index 00000000..2b9bcd3b --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SingleSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a4fcc9e482669344f8ff53d32f94f2f5 +timeCreated: 1611404284 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/StringSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/StringSerializer.cs new file mode 100644 index 00000000..09827b2a --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/StringSerializer.cs @@ -0,0 +1,49 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class StringSerializer : IProtoSerializer + { + public Type ExpectedType + { + get + { + return StringSerializer.expectedType; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return false; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private static readonly Type expectedType = typeof(string); + + public StringSerializer(TypeModel model) + { + } + + public void Write(object value, ProtoWriter dest) + { + ProtoWriter.WriteString((string)value, dest); + } + + public object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + return source.ReadString(); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/StringSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/StringSerializer.cs.meta new file mode 100644 index 00000000..b34fb67c --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/StringSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4349e44ff56a8094abcba104a2ebe4f1 +timeCreated: 1611403641 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SubItemSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SubItemSerializer.cs new file mode 100644 index 00000000..b2358d17 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SubItemSerializer.cs @@ -0,0 +1,96 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class SubItemSerializer : IProtoTypeSerializer, IProtoSerializer + { + Type IProtoSerializer.ExpectedType + { + get + { + return this.type; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return true; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private readonly int key; + + private readonly Type type; + + private readonly ISerializerProxy proxy; + + private readonly bool recursionCheck; + + bool IProtoTypeSerializer.HasCallbacks(TypeModel.CallbackType callbackType) + { + return ((IProtoTypeSerializer)this.proxy.Serializer).HasCallbacks(callbackType); + } + + bool IProtoTypeSerializer.CanCreateInstance() + { + return ((IProtoTypeSerializer)this.proxy.Serializer).CanCreateInstance(); + } + + void IProtoTypeSerializer.Callback(object value, TypeModel.CallbackType callbackType, SerializationContext context) + { + ((IProtoTypeSerializer)this.proxy.Serializer).Callback(value, callbackType, context); + } + + object IProtoTypeSerializer.CreateInstance(ProtoReader source) + { + return ((IProtoTypeSerializer)this.proxy.Serializer).CreateInstance(source); + } + + public SubItemSerializer(Type type, int key, ISerializerProxy proxy, bool recursionCheck) + { + bool flag = type == null; + if (flag) + { + throw new ArgumentNullException("type"); + } + bool flag2 = proxy == null; + if (flag2) + { + throw new ArgumentNullException("proxy"); + } + this.type = type; + this.proxy = proxy; + this.key = key; + this.recursionCheck = recursionCheck; + } + + void IProtoSerializer.Write(object value, ProtoWriter dest) + { + bool flag = this.recursionCheck; + if (flag) + { + ProtoWriter.WriteObject(value, this.key, dest); + } + else + { + ProtoWriter.WriteRecursionSafeObject(value, this.key, dest); + } + } + + object IProtoSerializer.Read(object value, ProtoReader source) + { + return ProtoReader.ReadObject(value, this.key, source); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SubItemSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SubItemSerializer.cs.meta new file mode 100644 index 00000000..f2088d37 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SubItemSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: af8ec618884c3e846a0aa0126f79685d +timeCreated: 1611404345 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SurrogateSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SurrogateSerializer.cs new file mode 100644 index 00000000..d7f171a5 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SurrogateSerializer.cs @@ -0,0 +1,154 @@ +using System; +using System.Reflection; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class SurrogateSerializer : IProtoTypeSerializer, IProtoSerializer + { + public bool ReturnsValue + { + get + { + return false; + } + } + + public bool RequiresOldValue + { + get + { + return true; + } + } + + public Type ExpectedType + { + get + { + return this.forType; + } + } + + private readonly Type forType; + + private readonly Type declaredType; + + private readonly MethodInfo toTail; + + private readonly MethodInfo fromTail; + + private IProtoTypeSerializer rootTail; + + bool IProtoTypeSerializer.HasCallbacks(TypeModel.CallbackType callbackType) + { + return false; + } + + bool IProtoTypeSerializer.CanCreateInstance() + { + return false; + } + + object IProtoTypeSerializer.CreateInstance(ProtoReader source) + { + throw new NotSupportedException(); + } + + void IProtoTypeSerializer.Callback(object value, TypeModel.CallbackType callbackType, SerializationContext context) + { + } + + public SurrogateSerializer(TypeModel model, Type forType, Type declaredType, IProtoTypeSerializer rootTail) + { + Helpers.DebugAssert(forType != null, "forType"); + Helpers.DebugAssert(declaredType != null, "declaredType"); + Helpers.DebugAssert(rootTail != null, "rootTail"); + Helpers.DebugAssert(rootTail.RequiresOldValue, "RequiresOldValue"); + Helpers.DebugAssert(!rootTail.ReturnsValue, "ReturnsValue"); + Helpers.DebugAssert(declaredType == rootTail.ExpectedType || Helpers.IsSubclassOf(declaredType, rootTail.ExpectedType)); + this.forType = forType; + this.declaredType = declaredType; + this.rootTail = rootTail; + this.toTail = this.GetConversion(model, true); + this.fromTail = this.GetConversion(model, false); + } + + private static bool HasCast(TypeModel model, Type type, Type from, Type to, out MethodInfo op) + { + MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); + Type type2 = null; + foreach (MethodInfo methodInfo in methods) + { + bool flag = methodInfo.ReturnType != to; + if (!flag) + { + ParameterInfo[] parameters = methodInfo.GetParameters(); + bool flag2 = parameters.Length == 1 && parameters[0].ParameterType == from; + if (flag2) + { + bool flag3 = type2 == null; + if (flag3) + { + type2 = model.MapType(typeof(ProtoConverterAttribute), false); + bool flag4 = type2 == null; + if (flag4) + { + break; + } + } + bool flag5 = methodInfo.IsDefined(type2, true); + if (flag5) + { + op = methodInfo; + return true; + } + } + } + } + foreach (MethodInfo methodInfo2 in methods) + { + bool flag6 = (methodInfo2.Name != "op_Implicit" && methodInfo2.Name != "op_Explicit") || methodInfo2.ReturnType != to; + if (!flag6) + { + ParameterInfo[] parameters = methodInfo2.GetParameters(); + bool flag7 = parameters.Length == 1 && parameters[0].ParameterType == from; + if (flag7) + { + op = methodInfo2; + return true; + } + } + } + op = null; + return false; + } + + public MethodInfo GetConversion(TypeModel model, bool toTail) + { + Type to = toTail ? this.declaredType : this.forType; + Type from = toTail ? this.forType : this.declaredType; + MethodInfo result; + bool flag = SurrogateSerializer.HasCast(model, this.declaredType, from, to, out result) || SurrogateSerializer.HasCast(model, this.forType, from, to, out result); + if (flag) + { + return result; + } + throw new InvalidOperationException("No suitable conversion operator found for surrogate: " + this.forType.FullName + " / " + this.declaredType.FullName); + } + + public void Write(object value, ProtoWriter writer) + { + ProtoDecoratorBase.s_argsWrite[0] = value; + this.rootTail.Write(this.toTail.Invoke(null, ProtoDecoratorBase.s_argsWrite), writer); + } + + public object Read(object value, ProtoReader source) + { + ProtoDecoratorBase.s_argsRead[0] = value; + value = this.toTail.Invoke(null, ProtoDecoratorBase.s_argsRead); + ProtoDecoratorBase.s_argsRead[0] = this.rootTail.Read(value, source); + return this.fromTail.Invoke(null, ProtoDecoratorBase.s_argsRead); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SurrogateSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SurrogateSerializer.cs.meta new file mode 100644 index 00000000..eb6eeaac --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SurrogateSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4320ebf7d1587cb41a71815ac5e941a8 +timeCreated: 1611403641 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SystemTypeSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SystemTypeSerializer.cs new file mode 100644 index 00000000..1cc322d4 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SystemTypeSerializer.cs @@ -0,0 +1,49 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class SystemTypeSerializer : IProtoSerializer + { + public Type ExpectedType + { + get + { + return SystemTypeSerializer.expectedType; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return false; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private static readonly Type expectedType = typeof(Type); + + public SystemTypeSerializer(TypeModel model) + { + } + + void IProtoSerializer.Write(object value, ProtoWriter dest) + { + ProtoWriter.WriteType((Type)value, dest); + } + + object IProtoSerializer.Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + return source.ReadType(); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SystemTypeSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SystemTypeSerializer.cs.meta new file mode 100644 index 00000000..fd810f93 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SystemTypeSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 316b036e681598744a7a6aa9fa12a8fc +timeCreated: 1611403545 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TagDecorator.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TagDecorator.cs new file mode 100644 index 00000000..7a0e390f --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TagDecorator.cs @@ -0,0 +1,105 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class TagDecorator : ProtoDecoratorBase, IProtoTypeSerializer, IProtoSerializer + { + public override Type ExpectedType + { + get + { + return this.Tail.ExpectedType; + } + } + + public override bool RequiresOldValue + { + get + { + return this.Tail.RequiresOldValue; + } + } + + public override bool ReturnsValue + { + get + { + return this.Tail.ReturnsValue; + } + } + + private bool NeedsHint + { + get + { + return (this.wireType & (WireType)(-8)) > WireType.Variant; + } + } + + private readonly bool strict; + + private readonly int fieldNumber; + + private readonly WireType wireType; + + public bool HasCallbacks(TypeModel.CallbackType callbackType) + { + IProtoTypeSerializer protoTypeSerializer = this.Tail as IProtoTypeSerializer; + return protoTypeSerializer != null && protoTypeSerializer.HasCallbacks(callbackType); + } + + public bool CanCreateInstance() + { + IProtoTypeSerializer protoTypeSerializer = this.Tail as IProtoTypeSerializer; + return protoTypeSerializer != null && protoTypeSerializer.CanCreateInstance(); + } + + public object CreateInstance(ProtoReader source) + { + return ((IProtoTypeSerializer)this.Tail).CreateInstance(source); + } + + public void Callback(object value, TypeModel.CallbackType callbackType, SerializationContext context) + { + IProtoTypeSerializer protoTypeSerializer = this.Tail as IProtoTypeSerializer; + bool flag = protoTypeSerializer != null; + if (flag) + { + protoTypeSerializer.Callback(value, callbackType, context); + } + } + + public TagDecorator(int fieldNumber, WireType wireType, bool strict, IProtoSerializer tail) : base(tail) + { + this.fieldNumber = fieldNumber; + this.wireType = wireType; + this.strict = strict; + } + + public override object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(this.fieldNumber == source.FieldNumber); + bool flag = this.strict; + if (flag) + { + source.Assert(this.wireType); + } + else + { + bool needsHint = this.NeedsHint; + if (needsHint) + { + source.Hint(this.wireType); + } + } + return this.Tail.Read(value, source); + } + + public override void Write(object value, ProtoWriter dest) + { + ProtoWriter.WriteFieldHeader(this.fieldNumber, this.wireType, dest); + this.Tail.Write(value, dest); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TagDecorator.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TagDecorator.cs.meta new file mode 100644 index 00000000..47c539c0 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TagDecorator.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f5c00b69b85f4714b903019fd5c6d4ec +timeCreated: 1611404877 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TimeSpanSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TimeSpanSerializer.cs new file mode 100644 index 00000000..650a2fa8 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TimeSpanSerializer.cs @@ -0,0 +1,49 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class TimeSpanSerializer : IProtoSerializer + { + public Type ExpectedType + { + get + { + return TimeSpanSerializer.expectedType; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return false; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private static readonly Type expectedType = typeof(TimeSpan); + + public TimeSpanSerializer(TypeModel model) + { + } + + public object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + return BclHelpers.ReadTimeSpan(source); + } + + public void Write(object value, ProtoWriter dest) + { + BclHelpers.WriteTimeSpan((TimeSpan)value, dest); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TimeSpanSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TimeSpanSerializer.cs.meta new file mode 100644 index 00000000..e9a11954 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TimeSpanSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8274313ccbb1a974b835114e01a78f04 +timeCreated: 1611404040 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TupleSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TupleSerializer.cs new file mode 100644 index 00000000..49424ffb --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TupleSerializer.cs @@ -0,0 +1,211 @@ +using System; +using System.Reflection; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class TupleSerializer : IProtoTypeSerializer, IProtoSerializer + { + public Type ExpectedType + { + get + { + return this.ctor.DeclaringType; + } + } + + public bool RequiresOldValue + { + get + { + return true; + } + } + + public bool ReturnsValue + { + get + { + return false; + } + } + + private readonly MemberInfo[] members; + + private readonly ConstructorInfo ctor; + + private IProtoSerializer[] tails; + + public TupleSerializer(RuntimeTypeModel model, ConstructorInfo ctor, MemberInfo[] members) + { + bool flag = ctor == null; + if (flag) + { + throw new ArgumentNullException("ctor"); + } + bool flag2 = members == null; + if (flag2) + { + throw new ArgumentNullException("members"); + } + this.ctor = ctor; + this.members = members; + this.tails = new IProtoSerializer[members.Length]; + ParameterInfo[] parameters = ctor.GetParameters(); + for (int i = 0; i < members.Length; i++) + { + Type parameterType = parameters[i].ParameterType; + Type type = null; + Type concreteType = null; + MetaType.ResolveListTypes(model, parameterType, ref type, ref concreteType); + Type type2 = (type == null) ? parameterType : type; + bool asReference = false; + int num = model.FindOrAddAuto(type2, false, true, false); + bool flag3 = num >= 0; + if (flag3) + { + asReference = model[type2].AsReferenceDefault; + } + WireType wireType; + IProtoSerializer protoSerializer = ValueMember.TryGetCoreSerializer(model, DataFormat.Default, type2, out wireType, asReference, false, false, true); + bool flag4 = protoSerializer == null; + if (flag4) + { + throw new InvalidOperationException("No serializer defined for type: " + type2.FullName); + } + protoSerializer = new TagDecorator(i + 1, wireType, false, protoSerializer); + bool flag5 = type == null; + IProtoSerializer protoSerializer2; + if (flag5) + { + protoSerializer2 = protoSerializer; + } + else + { + bool isArray = parameterType.IsArray; + if (isArray) + { + protoSerializer2 = new ArrayDecorator(model, protoSerializer, i + 1, false, wireType, parameterType, false, false); + } + else + { + protoSerializer2 = ListDecorator.Create(model, parameterType, concreteType, protoSerializer, i + 1, false, wireType, true, false, false); + } + } + this.tails[i] = protoSerializer2; + } + } + + public bool HasCallbacks(TypeModel.CallbackType callbackType) + { + return false; + } + + void IProtoTypeSerializer.Callback(object value, TypeModel.CallbackType callbackType, SerializationContext context) + { + } + + object IProtoTypeSerializer.CreateInstance(ProtoReader source) + { + throw new NotSupportedException(); + } + + private object GetValue(object obj, int index) + { + PropertyInfo propertyInfo; + bool flag = (propertyInfo = (this.members[index] as PropertyInfo)) != null; + object result; + if (flag) + { + bool flag2 = obj == null; + if (flag2) + { + result = (Helpers.IsValueType(propertyInfo.PropertyType) ? Activator.CreateInstance(propertyInfo.PropertyType) : null); + } + else + { + result = propertyInfo.GetValue(obj, null); + } + } + else + { + FieldInfo fieldInfo; + bool flag3 = (fieldInfo = (this.members[index] as FieldInfo)) != null; + if (!flag3) + { + throw new InvalidOperationException(); + } + bool flag4 = obj == null; + if (flag4) + { + result = (Helpers.IsValueType(fieldInfo.FieldType) ? Activator.CreateInstance(fieldInfo.FieldType) : null); + } + else + { + result = fieldInfo.GetValue(obj); + } + } + return result; + } + + public object Read(object value, ProtoReader source) + { + object[] array = new object[this.members.Length]; + bool flag = false; + bool flag2 = value == null; + if (flag2) + { + flag = true; + } + for (int i = 0; i < array.Length; i++) + { + array[i] = this.GetValue(value, i); + } + int num; + while ((num = source.ReadFieldHeader()) > 0) + { + flag = true; + bool flag3 = num <= this.tails.Length; + if (flag3) + { + IProtoSerializer protoSerializer = this.tails[num - 1]; + array[num - 1] = this.tails[num - 1].Read(protoSerializer.RequiresOldValue ? array[num - 1] : null, source); + } + else + { + source.SkipField(); + } + } + return flag ? this.ctor.Invoke(array) : value; + } + + public void Write(object value, ProtoWriter dest) + { + for (int i = 0; i < this.tails.Length; i++) + { + object value2 = this.GetValue(value, i); + bool flag = value2 != null; + if (flag) + { + this.tails[i].Write(value2, dest); + } + } + } + + private Type GetMemberType(int index) + { + Type memberType = Helpers.GetMemberType(this.members[index]); + bool flag = memberType == null; + if (flag) + { + throw new InvalidOperationException(); + } + return memberType; + } + + bool IProtoTypeSerializer.CanCreateInstance() + { + return false; + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TupleSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TupleSerializer.cs.meta new file mode 100644 index 00000000..864aa85d --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TupleSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 824ff1f17fa0ade46834f8070e773b2b +timeCreated: 1611404039 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TypeSerializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TypeSerializer.cs new file mode 100644 index 00000000..fd8fe62c --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TypeSerializer.cs @@ -0,0 +1,445 @@ +using System; +using System.Reflection; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class TypeSerializer : IProtoTypeSerializer, IProtoSerializer + { + public Type ExpectedType + { + get + { + return this.forType; + } + } + + private bool CanHaveInheritance + { + get + { + return (this.forType.IsClass || this.forType.IsInterface) && !this.forType.IsSealed; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return true; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return false; + } + } + + private readonly Type forType; + + private readonly Type constructType; + + private readonly IProtoSerializer[] serializers; + + private readonly int[] fieldNumbers; + + private readonly bool isRootType; + + private readonly bool useConstructor; + + private readonly bool isExtensible; + + private readonly bool hasConstructor; + + private readonly CallbackSet callbacks; + + private readonly MethodInfo[] baseCtorCallbacks; + + private readonly MethodInfo factory; + + private static readonly Type iextensible = typeof(IExtensible); + + public bool HasCallbacks(TypeModel.CallbackType callbackType) + { + bool flag = this.callbacks != null && this.callbacks[callbackType] != null; + bool result; + if (flag) + { + result = true; + } + else + { + for (int i = 0; i < this.serializers.Length; i++) + { + bool flag2 = this.serializers[i].ExpectedType != this.forType && ((IProtoTypeSerializer)this.serializers[i]).HasCallbacks(callbackType); + if (flag2) + { + return true; + } + } + result = false; + } + return result; + } + + public TypeSerializer(TypeModel model, Type forType, int[] fieldNumbers, IProtoSerializer[] serializers, MethodInfo[] baseCtorCallbacks, bool isRootType, bool useConstructor, CallbackSet callbacks, Type constructType, MethodInfo factory) + { + Helpers.DebugAssert(forType != null); + Helpers.DebugAssert(fieldNumbers != null); + Helpers.DebugAssert(serializers != null); + Helpers.DebugAssert(fieldNumbers.Length == serializers.Length); + Helpers.Sort(fieldNumbers, serializers); + bool flag = false; + for (int i = 1; i < fieldNumbers.Length; i++) + { + bool flag2 = fieldNumbers[i] == fieldNumbers[i - 1]; + if (flag2) + { + throw new InvalidOperationException("Duplicate field-number detected; " + fieldNumbers[i].ToString() + " on: " + forType.FullName); + } + bool flag3 = !flag && serializers[i].ExpectedType != forType; + if (flag3) + { + flag = true; + } + } + this.forType = forType; + this.factory = factory; + bool flag4 = constructType == null; + if (flag4) + { + constructType = forType; + } + else + { + bool flag5 = !forType.IsAssignableFrom(constructType); + if (flag5) + { + throw new InvalidOperationException(forType.FullName + " cannot be assigned from " + constructType.FullName); + } + } + this.constructType = constructType; + this.serializers = serializers; + this.fieldNumbers = fieldNumbers; + this.callbacks = callbacks; + this.isRootType = isRootType; + this.useConstructor = useConstructor; + bool flag6 = baseCtorCallbacks != null && baseCtorCallbacks.Length == 0; + if (flag6) + { + baseCtorCallbacks = null; + } + this.baseCtorCallbacks = baseCtorCallbacks; + bool flag7 = Helpers.GetUnderlyingType(forType) != null; + if (flag7) + { + throw new ArgumentException("Cannot create a TypeSerializer for nullable types", "forType"); + } + bool flag8 = model.MapType(TypeSerializer.iextensible).IsAssignableFrom(forType); + if (flag8) + { + bool flag9 = forType.IsValueType || !isRootType || flag; + if (flag9) + { + throw new NotSupportedException("IExtensible is not supported in structs or classes with inheritance"); + } + this.isExtensible = true; + } + this.hasConstructor = (!constructType.IsAbstract && Helpers.GetConstructor(constructType, Helpers.EmptyTypes, true) != null); + bool flag10 = constructType != forType && useConstructor && !this.hasConstructor; + if (flag10) + { + throw new ArgumentException("The supplied default implementation cannot be created: " + constructType.FullName, "constructType"); + } + } + + bool IProtoTypeSerializer.CanCreateInstance() + { + return true; + } + + object IProtoTypeSerializer.CreateInstance(ProtoReader source) + { + return this.CreateInstance(source, false); + } + + public void Callback(object value, TypeModel.CallbackType callbackType, SerializationContext context) + { + bool flag = this.callbacks != null; + if (flag) + { + this.InvokeCallback(this.callbacks[callbackType], value, context); + } + IProtoTypeSerializer protoTypeSerializer = (IProtoTypeSerializer)this.GetMoreSpecificSerializer(value); + bool flag2 = protoTypeSerializer != null; + if (flag2) + { + protoTypeSerializer.Callback(value, callbackType, context); + } + } + + private IProtoSerializer GetMoreSpecificSerializer(object value) + { + bool flag = !this.CanHaveInheritance; + IProtoSerializer result; + if (flag) + { + result = null; + } + else + { + Type type = value.GetType(); + bool flag2 = type == this.forType; + if (flag2) + { + result = null; + } + else + { + for (int i = 0; i < this.serializers.Length; i++) + { + IProtoSerializer protoSerializer = this.serializers[i]; + bool flag3 = protoSerializer.ExpectedType != this.forType && Helpers.IsAssignableFrom(protoSerializer.ExpectedType, type); + if (flag3) + { + return protoSerializer; + } + } + bool flag4 = type == this.constructType; + if (flag4) + { + result = null; + } + else + { + TypeModel.ThrowUnexpectedSubtype(this.forType, type); + result = null; + } + } + } + return result; + } + + public void Write(object value, ProtoWriter dest) + { + bool flag = this.isRootType; + if (flag) + { + this.Callback(value, TypeModel.CallbackType.BeforeSerialize, dest.Context); + } + IProtoSerializer moreSpecificSerializer = this.GetMoreSpecificSerializer(value); + bool flag2 = moreSpecificSerializer != null; + if (flag2) + { + moreSpecificSerializer.Write(value, dest); + } + for (int i = 0; i < this.serializers.Length; i++) + { + IProtoSerializer protoSerializer = this.serializers[i]; + bool flag3 = protoSerializer.ExpectedType == this.forType; + if (flag3) + { + protoSerializer.Write(value, dest); + } + } + bool flag4 = this.isExtensible; + if (flag4) + { + ProtoWriter.AppendExtensionData((IExtensible)value, dest); + } + bool flag5 = this.isRootType; + if (flag5) + { + this.Callback(value, TypeModel.CallbackType.AfterSerialize, dest.Context); + } + } + + public object Read(object value, ProtoReader source) + { + bool flag = this.isRootType && value != null; + if (flag) + { + this.Callback(value, TypeModel.CallbackType.BeforeDeserialize, source.Context); + } + int num = 0; + int num2 = 0; + int num3; + while ((num3 = source.ReadFieldHeader()) > 0) + { + bool flag2 = false; + bool flag3 = num3 < num; + if (flag3) + { + num2 = (num = 0); + } + for (int i = num2; i < this.fieldNumbers.Length; i++) + { + bool flag4 = this.fieldNumbers[i] == num3; + if (flag4) + { + IProtoSerializer protoSerializer = this.serializers[i]; + Type expectedType = protoSerializer.ExpectedType; + bool flag5 = value == null; + if (flag5) + { + bool flag6 = expectedType == this.forType; + if (flag6) + { + value = this.CreateInstance(source, true); + } + } + else + { + bool flag7 = expectedType != this.forType && ((IProtoTypeSerializer)protoSerializer).CanCreateInstance() && expectedType.IsSubclassOf(value.GetType()); + if (flag7) + { + value = ProtoReader.Merge(source, value, ((IProtoTypeSerializer)protoSerializer).CreateInstance(source)); + } + } + bool returnsValue = protoSerializer.ReturnsValue; + if (returnsValue) + { + value = protoSerializer.Read(value, source); + } + else + { + protoSerializer.Read(value, source); + } + num2 = i; + num = num3; + flag2 = true; + break; + } + } + bool flag8 = !flag2; + if (flag8) + { + bool flag9 = value == null; + if (flag9) + { + value = this.CreateInstance(source, true); + } + bool flag10 = this.isExtensible; + if (flag10) + { + source.AppendExtensionData((IExtensible)value); + } + else + { + source.SkipField(); + } + } + } + bool flag11 = value == null; + if (flag11) + { + value = this.CreateInstance(source, true); + } + bool flag12 = this.isRootType; + if (flag12) + { + this.Callback(value, TypeModel.CallbackType.AfterDeserialize, source.Context); + } + return value; + } + + private object InvokeCallback(MethodInfo method, object obj, SerializationContext context) + { + object result = null; + bool flag = method != null; + if (flag) + { + ParameterInfo[] parameters = method.GetParameters(); + int num = parameters.Length; + object[] array; + bool flag2; + if (num != 0) + { + array = new object[parameters.Length]; + flag2 = true; + for (int i = 0; i < array.Length; i++) + { + Type parameterType = parameters[i].ParameterType; + bool flag3 = parameterType == typeof(SerializationContext); + object obj2; + if (flag3) + { + obj2 = context; + } + else + { + bool flag4 = parameterType == typeof(Type); + if (flag4) + { + obj2 = this.constructType; + } + else + { + obj2 = null; + flag2 = false; + } + } + array[i] = obj2; + } + } + else + { + array = null; + flag2 = true; + } + bool flag5 = flag2; + if (!flag5) + { + throw CallbackSet.CreateInvalidCallbackSignature(method); + } + result = method.Invoke(obj, array); + } + return result; + } + + private object CreateInstance(ProtoReader source, bool includeLocalCallback) + { + bool flag = this.factory != null; + object obj; + if (flag) + { + obj = this.InvokeCallback(this.factory, null, source.Context); + } + else + { + bool flag2 = this.useConstructor; + if (flag2) + { + bool flag3 = !this.hasConstructor; + if (flag3) + { + TypeModel.ThrowCannotCreateInstance(this.constructType); + } + obj = Activator.CreateInstance(this.constructType, true); + } + else + { + obj = BclHelpers.GetUninitializedObject(this.constructType); + } + } + ProtoReader.NoteObject(obj, source); + bool flag4 = this.baseCtorCallbacks != null; + if (flag4) + { + for (int i = 0; i < this.baseCtorCallbacks.Length; i++) + { + this.InvokeCallback(this.baseCtorCallbacks[i], obj, source.Context); + } + } + bool flag5 = includeLocalCallback && this.callbacks != null; + if (flag5) + { + this.InvokeCallback(this.callbacks.BeforeDeserialize, obj, source.Context); + } + return obj; + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TypeSerializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TypeSerializer.cs.meta new file mode 100644 index 00000000..f8570d91 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/TypeSerializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ef593d3c48d31404290d6442b94fe22c +timeCreated: 1611404803 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt16Serializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt16Serializer.cs new file mode 100644 index 00000000..7819e0a6 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt16Serializer.cs @@ -0,0 +1,49 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal class UInt16Serializer : IProtoSerializer + { + public virtual Type ExpectedType + { + get + { + return UInt16Serializer.expectedType; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return false; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private static readonly Type expectedType = typeof(ushort); + + public UInt16Serializer(TypeModel model) + { + } + + public virtual object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + return source.ReadUInt16(); + } + + public virtual void Write(object value, ProtoWriter dest) + { + ProtoWriter.WriteUInt16((ushort)value, dest); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt16Serializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt16Serializer.cs.meta new file mode 100644 index 00000000..f66f3529 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt16Serializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 70340302d41d7a34780704e67a77cd8f +timeCreated: 1611403931 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt32Serializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt32Serializer.cs new file mode 100644 index 00000000..1f63d4d8 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt32Serializer.cs @@ -0,0 +1,49 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class UInt32Serializer : IProtoSerializer + { + public Type ExpectedType + { + get + { + return UInt32Serializer.expectedType; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return false; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private static readonly Type expectedType = typeof(uint); + + public UInt32Serializer(TypeModel model) + { + } + + public object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + return source.ReadUInt32(); + } + + public void Write(object value, ProtoWriter dest) + { + ProtoWriter.WriteUInt32((uint)value, dest); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt32Serializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt32Serializer.cs.meta new file mode 100644 index 00000000..da05d5e0 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt32Serializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f5eebc15e3c087148b1105452e3d6d7a +timeCreated: 1611404878 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt64Serializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt64Serializer.cs new file mode 100644 index 00000000..82790b63 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt64Serializer.cs @@ -0,0 +1,49 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class UInt64Serializer : IProtoSerializer + { + public Type ExpectedType + { + get + { + return UInt64Serializer.expectedType; + } + } + + bool IProtoSerializer.RequiresOldValue + { + get + { + return false; + } + } + + bool IProtoSerializer.ReturnsValue + { + get + { + return true; + } + } + + private static readonly Type expectedType = typeof(ulong); + + public UInt64Serializer(TypeModel model) + { + } + + public object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + return source.ReadUInt64(); + } + + public void Write(object value, ProtoWriter dest) + { + ProtoWriter.WriteUInt64((ulong)value, dest); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt64Serializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt64Serializer.cs.meta new file mode 100644 index 00000000..c978dfa5 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UInt64Serializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f3cd11be3380d8a4590384028ff49928 +timeCreated: 1611404850 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UriDecorator.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UriDecorator.cs new file mode 100644 index 00000000..4150a604 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UriDecorator.cs @@ -0,0 +1,50 @@ +using System; +using ProtoBuf.Meta; + +namespace ProtoBuf.Serializers +{ + internal sealed class UriDecorator : ProtoDecoratorBase + { + public override Type ExpectedType + { + get + { + return UriDecorator.expectedType; + } + } + + public override bool RequiresOldValue + { + get + { + return false; + } + } + + public override bool ReturnsValue + { + get + { + return true; + } + } + + private static readonly Type expectedType = typeof(Uri); + + public UriDecorator(TypeModel model, IProtoSerializer tail) : base(tail) + { + } + + public override void Write(object value, ProtoWriter dest) + { + this.Tail.Write(((Uri)value).AbsoluteUri, dest); + } + + public override object Read(object value, ProtoReader source) + { + Helpers.DebugAssert(value == null); + string text = (string)this.Tail.Read(null, source); + return (text.Length == 0) ? null : new Uri(text); + } + } +} diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UriDecorator.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UriDecorator.cs.meta new file mode 100644 index 00000000..6ae76887 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/UriDecorator.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7e8f0a6082ce473469fae71e5d46f51c +timeCreated: 1611404005 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: -- cgit v1.1-26-g67d0