diff options
author | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
commit | 6eb915c129fc90c6f4c82ae097dd6ffad5239efc (patch) | |
tree | 7dd2be50edf41f36b60fac84696e731c13afe617 /Client/Assets/Scripts/XMainClient/ProtoBuf |
+scripts
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/ProtoBuf')
176 files changed, 17100 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/BclHelpers.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/BclHelpers.cs new file mode 100644 index 00000000..50452c07 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/BclHelpers.cs @@ -0,0 +1,659 @@ +using System;
+
+namespace ProtoBuf
+{
+ public static class BclHelpers
+ {
+ private const int FieldTimeSpanValue = 1;
+
+ private const int FieldTimeSpanScale = 2;
+
+ internal static readonly DateTime EpochOrigin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
+
+ private const int FieldDecimalLow = 1;
+
+ private const int FieldDecimalHigh = 2;
+
+ private const int FieldDecimalSignScale = 3;
+
+ private const int FieldGuidLow = 1;
+
+ private const int FieldGuidHigh = 2;
+
+ private const int FieldExistingObjectKey = 1;
+
+ private const int FieldNewObjectKey = 2;
+
+ private const int FieldExistingTypeKey = 3;
+
+ private const int FieldNewTypeKey = 4;
+
+ private const int FieldTypeName = 8;
+
+ private const int FieldObject = 10;
+
+ [Flags]
+ public enum NetObjectOptions : byte
+ {
+ None = 0,
+ AsReference = 1,
+ DynamicType = 2,
+ UseConstructor = 4,
+ LateSet = 8
+ }
+
+ public static object GetUninitializedObject(Type type)
+ {
+ throw new NotSupportedException("Constructor-skipping is not supported on this platform");
+ }
+
+ public static void WriteTimeSpan(TimeSpan timeSpan, ProtoWriter dest)
+ {
+ bool flag = dest == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("dest");
+ }
+ WireType wireType = dest.WireType;
+ if (wireType != WireType.Fixed64)
+ {
+ if (wireType - WireType.String > 1)
+ {
+ throw new ProtoException("Unexpected wire-type: " + dest.WireType.ToString());
+ }
+ long num = timeSpan.Ticks;
+ bool flag2 = timeSpan == TimeSpan.MaxValue;
+ TimeSpanScale timeSpanScale;
+ if (flag2)
+ {
+ num = 1L;
+ timeSpanScale = TimeSpanScale.MinMax;
+ }
+ else
+ {
+ bool flag3 = timeSpan == TimeSpan.MinValue;
+ if (flag3)
+ {
+ num = -1L;
+ timeSpanScale = TimeSpanScale.MinMax;
+ }
+ else
+ {
+ bool flag4 = num % 864000000000L == 0L;
+ if (flag4)
+ {
+ timeSpanScale = TimeSpanScale.Days;
+ num /= 864000000000L;
+ }
+ else
+ {
+ bool flag5 = num % 36000000000L == 0L;
+ if (flag5)
+ {
+ timeSpanScale = TimeSpanScale.Hours;
+ num /= 36000000000L;
+ }
+ else
+ {
+ bool flag6 = num % 600000000L == 0L;
+ if (flag6)
+ {
+ timeSpanScale = TimeSpanScale.Minutes;
+ num /= 600000000L;
+ }
+ else
+ {
+ bool flag7 = num % 10000000L == 0L;
+ if (flag7)
+ {
+ timeSpanScale = TimeSpanScale.Seconds;
+ num /= 10000000L;
+ }
+ else
+ {
+ bool flag8 = num % 10000L == 0L;
+ if (flag8)
+ {
+ timeSpanScale = TimeSpanScale.Milliseconds;
+ num /= 10000L;
+ }
+ else
+ {
+ timeSpanScale = TimeSpanScale.Ticks;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ SubItemToken token = ProtoWriter.StartSubItem(null, dest);
+ bool flag9 = num != 0L;
+ if (flag9)
+ {
+ ProtoWriter.WriteFieldHeader(1, WireType.SignedVariant, dest);
+ ProtoWriter.WriteInt64(num, dest);
+ }
+ bool flag10 = timeSpanScale > TimeSpanScale.Days;
+ if (flag10)
+ {
+ ProtoWriter.WriteFieldHeader(2, WireType.Variant, dest);
+ ProtoWriter.WriteInt32((int)timeSpanScale, dest);
+ }
+ ProtoWriter.EndSubItem(token, dest);
+ }
+ else
+ {
+ ProtoWriter.WriteInt64(timeSpan.Ticks, dest);
+ }
+ }
+
+ public static TimeSpan ReadTimeSpan(ProtoReader source)
+ {
+ long num = BclHelpers.ReadTimeSpanTicks(source);
+ bool flag = num == long.MinValue;
+ TimeSpan result;
+ if (flag)
+ {
+ result = TimeSpan.MinValue;
+ }
+ else
+ {
+ bool flag2 = num == long.MaxValue;
+ if (flag2)
+ {
+ result = TimeSpan.MaxValue;
+ }
+ else
+ {
+ result = TimeSpan.FromTicks(num);
+ }
+ }
+ return result;
+ }
+
+ public static DateTime ReadDateTime(ProtoReader source)
+ {
+ long num = BclHelpers.ReadTimeSpanTicks(source);
+ bool flag = num == long.MinValue;
+ DateTime result;
+ if (flag)
+ {
+ result = DateTime.MinValue;
+ }
+ else
+ {
+ bool flag2 = num == long.MaxValue;
+ if (flag2)
+ {
+ result = DateTime.MaxValue;
+ }
+ else
+ {
+ result = BclHelpers.EpochOrigin.AddTicks(num);
+ }
+ }
+ return result;
+ }
+
+ public static void WriteDateTime(DateTime value, ProtoWriter dest)
+ {
+ bool flag = dest == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("dest");
+ }
+ WireType wireType = dest.WireType;
+ TimeSpan timeSpan;
+ if (wireType - WireType.String > 1)
+ {
+ timeSpan = value - BclHelpers.EpochOrigin;
+ }
+ else
+ {
+ bool flag2 = value == DateTime.MaxValue;
+ if (flag2)
+ {
+ timeSpan = TimeSpan.MaxValue;
+ }
+ else
+ {
+ bool flag3 = value == DateTime.MinValue;
+ if (flag3)
+ {
+ timeSpan = TimeSpan.MinValue;
+ }
+ else
+ {
+ timeSpan = value - BclHelpers.EpochOrigin;
+ }
+ }
+ }
+ BclHelpers.WriteTimeSpan(timeSpan, dest);
+ }
+
+ private static long ReadTimeSpanTicks(ProtoReader source)
+ {
+ WireType wireType = source.WireType;
+ long result;
+ if (wireType != WireType.Fixed64)
+ {
+ if (wireType - WireType.String > 1)
+ {
+ throw new ProtoException("Unexpected wire-type: " + source.WireType.ToString());
+ }
+ SubItemToken token = ProtoReader.StartSubItem(source);
+ TimeSpanScale timeSpanScale = TimeSpanScale.Days;
+ long num = 0L;
+ int num2;
+ while ((num2 = source.ReadFieldHeader()) > 0)
+ {
+ int num3 = num2;
+ if (num3 != 1)
+ {
+ if (num3 != 2)
+ {
+ source.SkipField();
+ }
+ else
+ {
+ timeSpanScale = (TimeSpanScale)source.ReadInt32();
+ }
+ }
+ else
+ {
+ source.Assert(WireType.SignedVariant);
+ num = source.ReadInt64();
+ }
+ }
+ ProtoReader.EndSubItem(token, source);
+ TimeSpanScale timeSpanScale2 = timeSpanScale;
+ switch (timeSpanScale2)
+ {
+ case TimeSpanScale.Days:
+ result = num * 864000000000L;
+ break;
+ case TimeSpanScale.Hours:
+ result = num * 36000000000L;
+ break;
+ case TimeSpanScale.Minutes:
+ result = num * 600000000L;
+ break;
+ case TimeSpanScale.Seconds:
+ result = num * 10000000L;
+ break;
+ case TimeSpanScale.Milliseconds:
+ result = num * 10000L;
+ break;
+ case TimeSpanScale.Ticks:
+ result = num;
+ break;
+ default:
+ {
+ if (timeSpanScale2 != TimeSpanScale.MinMax)
+ {
+ throw new ProtoException("Unknown timescale: " + timeSpanScale.ToString());
+ }
+ long num4 = num;
+ if (num4 != -1L)
+ {
+ if (num4 != 1L)
+ {
+ throw new ProtoException("Unknown min/max value: " + num.ToString());
+ }
+ result = long.MaxValue;
+ }
+ else
+ {
+ result = long.MinValue;
+ }
+ break;
+ }
+ }
+ }
+ else
+ {
+ result = source.ReadInt64();
+ }
+ return result;
+ }
+
+ public static decimal ReadDecimal(ProtoReader reader)
+ {
+ ulong num = 0UL;
+ uint num2 = 0u;
+ uint num3 = 0u;
+ SubItemToken token = ProtoReader.StartSubItem(reader);
+ int num4;
+ while ((num4 = reader.ReadFieldHeader()) > 0)
+ {
+ switch (num4)
+ {
+ case 1:
+ num = reader.ReadUInt64();
+ break;
+ case 2:
+ num2 = reader.ReadUInt32();
+ break;
+ case 3:
+ num3 = reader.ReadUInt32();
+ break;
+ default:
+ reader.SkipField();
+ break;
+ }
+ }
+ ProtoReader.EndSubItem(token, reader);
+ bool flag = num == 0UL && num2 == 0u;
+ decimal result;
+ if (flag)
+ {
+ result = 0m;
+ }
+ else
+ {
+ int lo = (int)(num & /*(ulong)-1 */ulong.MaxValue);
+ int mid = (int)(num >> 32 & /*(ulong)-1*/ulong.MaxValue);
+ int hi = (int)num2;
+ bool isNegative = (num3 & 1u) == 1u;
+ byte scale = (byte)((num3 & 510u) >> 1);
+ result = new decimal(lo, mid, hi, isNegative, scale);
+ }
+ return result;
+ }
+
+ public static void WriteDecimal(decimal value, ProtoWriter writer)
+ {
+ int[] bits = decimal.GetBits(value);
+ ulong num = (ulong)((ulong)((long)bits[1]) << 32);
+ ulong num2 = (ulong)((long)bits[0] & (long)(long.MaxValue));
+ ulong num3 = num | num2;
+ uint num4 = (uint)bits[2];
+ uint num5 = (uint)((bits[3] >> 15 & 510) | (bits[3] >> 31 & 1));
+ SubItemToken token = ProtoWriter.StartSubItem(null, writer);
+ bool flag = num3 > 0UL;
+ if (flag)
+ {
+ ProtoWriter.WriteFieldHeader(1, WireType.Variant, writer);
+ ProtoWriter.WriteUInt64(num3, writer);
+ }
+ bool flag2 = num4 > 0u;
+ if (flag2)
+ {
+ ProtoWriter.WriteFieldHeader(2, WireType.Variant, writer);
+ ProtoWriter.WriteUInt32(num4, writer);
+ }
+ bool flag3 = num5 > 0u;
+ if (flag3)
+ {
+ ProtoWriter.WriteFieldHeader(3, WireType.Variant, writer);
+ ProtoWriter.WriteUInt32(num5, writer);
+ }
+ ProtoWriter.EndSubItem(token, writer);
+ }
+
+ public static void WriteGuid(Guid value, ProtoWriter dest)
+ {
+ byte[] data = value.ToByteArray();
+ SubItemToken token = ProtoWriter.StartSubItem(null, dest);
+ bool flag = value != Guid.Empty;
+ if (flag)
+ {
+ ProtoWriter.WriteFieldHeader(1, WireType.Fixed64, dest);
+ ProtoWriter.WriteBytes(data, 0, 8, dest);
+ ProtoWriter.WriteFieldHeader(2, WireType.Fixed64, dest);
+ ProtoWriter.WriteBytes(data, 8, 8, dest);
+ }
+ ProtoWriter.EndSubItem(token, dest);
+ }
+
+ public static Guid ReadGuid(ProtoReader source)
+ {
+ ulong num = 0UL;
+ ulong num2 = 0UL;
+ SubItemToken token = ProtoReader.StartSubItem(source);
+ int num3;
+ while ((num3 = source.ReadFieldHeader()) > 0)
+ {
+ int num4 = num3;
+ if (num4 != 1)
+ {
+ if (num4 != 2)
+ {
+ source.SkipField();
+ }
+ else
+ {
+ num2 = source.ReadUInt64();
+ }
+ }
+ else
+ {
+ num = source.ReadUInt64();
+ }
+ }
+ ProtoReader.EndSubItem(token, source);
+ bool flag = num == 0UL && num2 == 0UL;
+ Guid result;
+ if (flag)
+ {
+ result = Guid.Empty;
+ }
+ else
+ {
+ uint num5 = (uint)(num >> 32);
+ uint a = (uint)num;
+ uint num6 = (uint)(num2 >> 32);
+ uint num7 = (uint)num2;
+ result = new Guid((int)a, (short)num5, (short)(num5 >> 16), (byte)num7, (byte)(num7 >> 8), (byte)(num7 >> 16), (byte)(num7 >> 24), (byte)num6, (byte)(num6 >> 8), (byte)(num6 >> 16), (byte)(num6 >> 24));
+ }
+ return result;
+ }
+
+ public static object ReadNetObject(object value, ProtoReader source, int key, Type type, BclHelpers.NetObjectOptions options)
+ {
+ SubItemToken token = ProtoReader.StartSubItem(source);
+ int num = -1;
+ int num2 = -1;
+ int num3;
+ while ((num3 = source.ReadFieldHeader()) > 0)
+ {
+ switch (num3)
+ {
+ case 1:
+ {
+ int key2 = source.ReadInt32();
+ value = source.NetCache.GetKeyedObject(key2);
+ break;
+ }
+ case 2:
+ num = source.ReadInt32();
+ break;
+ case 3:
+ {
+ int key2 = source.ReadInt32();
+ type = (Type)source.NetCache.GetKeyedObject(key2);
+ key = source.GetTypeKey(ref type);
+ break;
+ }
+ case 4:
+ num2 = source.ReadInt32();
+ break;
+ case 5:
+ case 6:
+ case 7:
+ case 9:
+ goto IL_27E;
+ case 8:
+ {
+ string text = source.ReadString();
+ type = source.DeserializeType(text);
+ bool flag = type == null;
+ if (flag)
+ {
+ throw new ProtoException("Unable to resolve type: " + text + " (you can use the TypeModel.DynamicTypeFormatting event to provide a custom mapping)");
+ }
+ bool flag2 = type == typeof(string);
+ if (flag2)
+ {
+ key = -1;
+ }
+ else
+ {
+ key = source.GetTypeKey(ref type);
+ bool flag3 = key < 0;
+ if (flag3)
+ {
+ throw new InvalidOperationException("Dynamic type is not a contract-type: " + type.Name);
+ }
+ }
+ break;
+ }
+ case 10:
+ {
+ bool flag4 = type == typeof(string);
+ bool flag5 = value == null;
+ bool flag6 = flag5 && (flag4 || (options & BclHelpers.NetObjectOptions.LateSet) > BclHelpers.NetObjectOptions.None);
+ bool flag7 = num >= 0 && !flag6;
+ if (flag7)
+ {
+ bool flag8 = value == null;
+ if (flag8)
+ {
+ source.TrapNextObject(num);
+ }
+ else
+ {
+ source.NetCache.SetKeyedObject(num, value);
+ }
+ bool flag9 = num2 >= 0;
+ if (flag9)
+ {
+ source.NetCache.SetKeyedObject(num2, type);
+ }
+ }
+ object obj = value;
+ bool flag10 = flag4;
+ if (flag10)
+ {
+ value = source.ReadString();
+ }
+ else
+ {
+ value = ProtoReader.ReadTypedObject(obj, key, source, type);
+ }
+ bool flag11 = num >= 0;
+ if (flag11)
+ {
+ bool flag12 = flag5 && !flag6;
+ if (flag12)
+ {
+ obj = source.NetCache.GetKeyedObject(num);
+ }
+ bool flag13 = flag6;
+ if (flag13)
+ {
+ source.NetCache.SetKeyedObject(num, value);
+ bool flag14 = num2 >= 0;
+ if (flag14)
+ {
+ source.NetCache.SetKeyedObject(num2, type);
+ }
+ }
+ }
+ bool flag15 = num >= 0 && !flag6 && obj != value;
+ if (flag15)
+ {
+ throw new ProtoException("A reference-tracked object changed reference during deserialization");
+ }
+ bool flag16 = num < 0 && num2 >= 0;
+ if (flag16)
+ {
+ source.NetCache.SetKeyedObject(num2, type);
+ }
+ break;
+ }
+ default:
+ goto IL_27E;
+ }
+ continue;
+ IL_27E:
+ source.SkipField();
+ }
+ bool flag17 = num >= 0 && (options & BclHelpers.NetObjectOptions.AsReference) == BclHelpers.NetObjectOptions.None;
+ if (flag17)
+ {
+ throw new ProtoException("Object key in input stream, but reference-tracking was not expected");
+ }
+ ProtoReader.EndSubItem(token, source);
+ return value;
+ }
+
+ public static void WriteNetObject(object value, ProtoWriter dest, int key, BclHelpers.NetObjectOptions options)
+ {
+ bool flag = dest == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("dest");
+ }
+ bool flag2 = (options & BclHelpers.NetObjectOptions.DynamicType) > BclHelpers.NetObjectOptions.None;
+ bool flag3 = (options & BclHelpers.NetObjectOptions.AsReference) > BclHelpers.NetObjectOptions.None;
+ WireType wireType = dest.WireType;
+ SubItemToken token = ProtoWriter.StartSubItem(null, dest);
+ bool flag4 = true;
+ bool flag5 = flag3;
+ if (flag5)
+ {
+ bool flag6;
+ int value2 = dest.NetCache.AddObjectKey(value, out flag6);
+ ProtoWriter.WriteFieldHeader(flag6 ? 1 : 2, WireType.Variant, dest);
+ ProtoWriter.WriteInt32(value2, dest);
+ bool flag7 = flag6;
+ if (flag7)
+ {
+ flag4 = false;
+ }
+ }
+ bool flag8 = flag4;
+ if (flag8)
+ {
+ bool flag9 = flag2;
+ if (flag9)
+ {
+ Type type = value.GetType();
+ bool flag10 = !(value is string);
+ if (flag10)
+ {
+ key = dest.GetTypeKey(ref type);
+ bool flag11 = key < 0;
+ if (flag11)
+ {
+ throw new InvalidOperationException("Dynamic type is not a contract-type: " + type.Name);
+ }
+ }
+ bool flag12;
+ int value3 = dest.NetCache.AddObjectKey(type, out flag12);
+ ProtoWriter.WriteFieldHeader(flag12 ? 3 : 4, WireType.Variant, dest);
+ ProtoWriter.WriteInt32(value3, dest);
+ bool flag13 = !flag12;
+ if (flag13)
+ {
+ ProtoWriter.WriteFieldHeader(8, WireType.String, dest);
+ ProtoWriter.WriteString(dest.SerializeType(type), dest);
+ }
+ }
+ ProtoWriter.WriteFieldHeader(10, wireType, dest);
+ bool flag14 = value is string;
+ if (flag14)
+ {
+ ProtoWriter.WriteString((string)value, dest);
+ }
+ else
+ {
+ ProtoWriter.WriteObject(value, key, dest);
+ }
+ }
+ ProtoWriter.EndSubItem(token, dest);
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/BclHelpers.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/BclHelpers.cs.meta new file mode 100644 index 00000000..11421dcc --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/BclHelpers.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: cb4f7e7bf29811b48a2af2a46cf7c0c3 +timeCreated: 1611404545 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/BufferExtension.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/BufferExtension.cs new file mode 100644 index 00000000..2bae502e --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/BufferExtension.cs @@ -0,0 +1,72 @@ +using System;
+using System.IO;
+
+namespace ProtoBuf
+{
+ public sealed class BufferExtension : IExtension
+ {
+ private byte[] buffer;
+
+ int IExtension.GetLength()
+ {
+ return (this.buffer == null) ? 0 : this.buffer.Length;
+ }
+
+ Stream IExtension.BeginAppend()
+ {
+ return new MemoryStream();
+ }
+
+ void IExtension.EndAppend(Stream stream, bool commit)
+ {
+ try
+ {
+ int num = 0;
+ bool flag = commit && (num = (int)stream.Length) > 0;
+ if (flag)
+ {
+ MemoryStream memoryStream = (MemoryStream)stream;
+ bool flag2 = this.buffer == null;
+ if (flag2)
+ {
+ this.buffer = memoryStream.ToArray();
+ }
+ else
+ {
+ int num2 = this.buffer.Length;
+ byte[] to = new byte[num2 + num];
+ Helpers.BlockCopy(this.buffer, 0, to, 0, num2);
+ Helpers.BlockCopy(memoryStream.GetBuffer(), 0, to, num2, num);
+ this.buffer = to;
+ }
+ }
+ }
+ finally
+ {
+ if (stream != null)
+ {
+ ((IDisposable)stream).Dispose();
+ }
+ }
+ }
+
+ Stream IExtension.BeginQuery()
+ {
+ return (this.buffer == null) ? Stream.Null : new MemoryStream(this.buffer);
+ }
+
+ void IExtension.EndQuery(Stream stream)
+ {
+ try
+ {
+ }
+ finally
+ {
+ if (stream != null)
+ {
+ ((IDisposable)stream).Dispose();
+ }
+ }
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/BufferExtension.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/BufferExtension.cs.meta new file mode 100644 index 00000000..6a9c6aa6 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/BufferExtension.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 093a887d01b82564b920e35171554124 +timeCreated: 1611403151 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/BufferPool.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/BufferPool.cs new file mode 100644 index 00000000..36aabc3a --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/BufferPool.cs @@ -0,0 +1,87 @@ +using System;
+using System.Threading;
+
+namespace ProtoBuf
+{
+ internal sealed class BufferPool
+ {
+ private const int PoolSize = 20;
+
+ internal const int BufferLength = 1024;
+
+ private static readonly object[] pool = new object[20];
+
+ internal static void Flush()
+ {
+ for (int i = 0; i < BufferPool.pool.Length; i++)
+ {
+ Interlocked.Exchange(ref BufferPool.pool[i], null);
+ }
+ }
+
+ private BufferPool()
+ {
+ }
+
+ internal static byte[] GetBuffer()
+ {
+ for (int i = 0; i < BufferPool.pool.Length; i++)
+ {
+ object obj;
+ bool flag = (obj = Interlocked.Exchange(ref BufferPool.pool[i], null)) != null;
+ if (flag)
+ {
+ return (byte[])obj;
+ }
+ }
+ return new byte[1024];
+ }
+
+ internal static void ResizeAndFlushLeft(ref byte[] buffer, int toFitAtLeastBytes, int copyFromIndex, int copyBytes)
+ {
+ Helpers.DebugAssert(buffer != null);
+ Helpers.DebugAssert(toFitAtLeastBytes > buffer.Length);
+ Helpers.DebugAssert(copyFromIndex >= 0);
+ Helpers.DebugAssert(copyBytes >= 0);
+ int num = buffer.Length * 2;
+ bool flag = num < toFitAtLeastBytes;
+ if (flag)
+ {
+ num = toFitAtLeastBytes;
+ }
+ byte[] array = new byte[num];
+ bool flag2 = copyBytes > 0;
+ if (flag2)
+ {
+ Helpers.BlockCopy(buffer, copyFromIndex, array, 0, copyBytes);
+ }
+ bool flag3 = buffer.Length == 1024;
+ if (flag3)
+ {
+ BufferPool.ReleaseBufferToPool(ref buffer);
+ }
+ buffer = array;
+ }
+
+ internal static void ReleaseBufferToPool(ref byte[] buffer)
+ {
+ bool flag = buffer == null;
+ if (!flag)
+ {
+ bool flag2 = buffer.Length == 1024;
+ if (flag2)
+ {
+ for (int i = 0; i < BufferPool.pool.Length; i++)
+ {
+ bool flag3 = Interlocked.CompareExchange(ref BufferPool.pool[i], buffer, null) == null;
+ if (flag3)
+ {
+ break;
+ }
+ }
+ }
+ buffer = null;
+ }
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/BufferPool.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/BufferPool.cs.meta new file mode 100644 index 00000000..32eb47ff --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/BufferPool.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b9f1916d7d8c6984e979af269fcde17b +timeCreated: 1611404433 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/DataFormat.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/DataFormat.cs new file mode 100644 index 00000000..e53b59d5 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/DataFormat.cs @@ -0,0 +1,13 @@ +using System;
+
+namespace ProtoBuf
+{
+ public enum DataFormat
+ {
+ Default,
+ ZigZag,
+ TwosComplement,
+ FixedSize,
+ Group
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/DataFormat.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/DataFormat.cs.meta new file mode 100644 index 00000000..e19f0dd3 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/DataFormat.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f6699ef9eb3af6941a78cb34b4d81ef9 +timeCreated: 1611404881 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Extensible.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Extensible.cs new file mode 100644 index 00000000..3c33a044 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Extensible.cs @@ -0,0 +1,108 @@ +using System;
+using System.Collections;
+using System.Collections.Generic;
+using ProtoBuf.Meta;
+
+namespace ProtoBuf
+{
+ public abstract class Extensible : IExtensible
+ {
+ private IExtension extensionObject;
+
+ IExtension IExtensible.GetExtensionObject(bool createIfMissing)
+ {
+ return this.GetExtensionObject(createIfMissing);
+ }
+
+ protected virtual IExtension GetExtensionObject(bool createIfMissing)
+ {
+ return Extensible.GetExtensionObject(ref this.extensionObject, createIfMissing);
+ }
+
+ public static IExtension GetExtensionObject(ref IExtension extensionObject, bool createIfMissing)
+ {
+ bool flag = createIfMissing && extensionObject == null;
+ if (flag)
+ {
+ extensionObject = new BufferExtension();
+ }
+ return extensionObject;
+ }
+
+ public static void AppendValue<TValue>(IExtensible instance, int tag, TValue value)
+ {
+ Extensible.AppendValue<TValue>(instance, tag, DataFormat.Default, value);
+ }
+
+ public static void AppendValue<TValue>(IExtensible instance, int tag, DataFormat format, TValue value)
+ {
+ ExtensibleUtil.AppendExtendValue(RuntimeTypeModel.Default, instance, tag, format, value);
+ }
+
+ public static TValue GetValue<TValue>(IExtensible instance, int tag)
+ {
+ return Extensible.GetValue<TValue>(instance, tag, DataFormat.Default);
+ }
+
+ public static TValue GetValue<TValue>(IExtensible instance, int tag, DataFormat format)
+ {
+ TValue result;
+ Extensible.TryGetValue<TValue>(instance, tag, format, out result);
+ return result;
+ }
+
+ public static bool TryGetValue<TValue>(IExtensible instance, int tag, out TValue value)
+ {
+ return Extensible.TryGetValue<TValue>(instance, tag, DataFormat.Default, out value);
+ }
+
+ public static bool TryGetValue<TValue>(IExtensible instance, int tag, DataFormat format, out TValue value)
+ {
+ return Extensible.TryGetValue<TValue>(instance, tag, format, false, out value);
+ }
+
+ public static bool TryGetValue<TValue>(IExtensible instance, int tag, DataFormat format, bool allowDefinedTag, out TValue value)
+ {
+ value = default(TValue);
+ bool result = false;
+ foreach (TValue tvalue in ExtensibleUtil.GetExtendedValues<TValue>(instance, tag, format, true, allowDefinedTag))
+ {
+ value = tvalue;
+ result = true;
+ }
+ return result;
+ }
+
+ public static IEnumerable<TValue> GetValues<TValue>(IExtensible instance, int tag)
+ {
+ return ExtensibleUtil.GetExtendedValues<TValue>(instance, tag, DataFormat.Default, false, false);
+ }
+
+ public static IEnumerable<TValue> GetValues<TValue>(IExtensible instance, int tag, DataFormat format)
+ {
+ return ExtensibleUtil.GetExtendedValues<TValue>(instance, tag, format, false, false);
+ }
+
+ public static bool TryGetValue(TypeModel model, Type type, IExtensible instance, int tag, DataFormat format, bool allowDefinedTag, out object value)
+ {
+ value = null;
+ bool result = false;
+ foreach (object obj in ExtensibleUtil.GetExtendedValues(model, type, instance, tag, format, true, allowDefinedTag))
+ {
+ value = obj;
+ result = true;
+ }
+ return result;
+ }
+
+ public static IEnumerable GetValues(TypeModel model, Type type, IExtensible instance, int tag, DataFormat format)
+ {
+ return ExtensibleUtil.GetExtendedValues(model, type, instance, tag, format, false, false);
+ }
+
+ public static void AppendValue(TypeModel model, IExtensible instance, int tag, DataFormat format, object value)
+ {
+ ExtensibleUtil.AppendExtendValue(model, instance, tag, format, value);
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Extensible.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Extensible.cs.meta new file mode 100644 index 00000000..f8ccdbf9 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Extensible.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d9283a99346cfed4297e56586e046bf8 +timeCreated: 1611404642 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ExtensibleUtil.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/ExtensibleUtil.cs new file mode 100644 index 00000000..c4105259 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ExtensibleUtil.cs @@ -0,0 +1,109 @@ +using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using ProtoBuf.Meta;
+
+namespace ProtoBuf
+{
+ internal static class ExtensibleUtil
+ {
+ internal static IEnumerable<TValue> GetExtendedValues<TValue>(IExtensible instance, int tag, DataFormat format, bool singleton, bool allowDefinedTag)
+ {
+ foreach (object obj in ExtensibleUtil.GetExtendedValues(RuntimeTypeModel.Default, typeof(TValue), instance, tag, format, singleton, allowDefinedTag))
+ {
+ TValue value = (TValue)((object)obj);
+ yield return value;
+ value = default(TValue);
+ }
+ IEnumerator enumerator = null;
+ yield break;
+ yield break;
+ }
+
+ internal static IEnumerable GetExtendedValues(TypeModel model, Type type, IExtensible instance, int tag, DataFormat format, bool singleton, bool allowDefinedTag)
+ {
+ bool flag = instance == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("instance");
+ }
+ bool flag2 = tag <= 0;
+ if (flag2)
+ {
+ throw new ArgumentOutOfRangeException("tag");
+ }
+ IExtension extn = instance.GetExtensionObject(false);
+ bool flag3 = extn == null;
+ if (flag3)
+ {
+ yield break;
+ }
+ Stream stream = extn.BeginQuery();
+ object value = null;
+ ProtoReader reader = null;
+ try
+ {
+ SerializationContext ctx = new SerializationContext();
+ reader = ProtoReader.Create(stream, model, ctx, -1);
+ while (model.TryDeserializeAuxiliaryType(reader, format, tag, type, ref value, true, false, false, false) && value != null)
+ {
+ bool flag4 = !singleton;
+ if (flag4)
+ {
+ yield return value;
+ value = null;
+ }
+ }
+ bool flag5 = singleton && value != null;
+ if (flag5)
+ {
+ yield return value;
+ }
+ ctx = null;
+ }
+ finally
+ {
+ ProtoReader.Recycle(reader);
+ extn.EndQuery(stream);
+ }
+ yield break;
+ yield break;
+ }
+
+ internal static void AppendExtendValue(TypeModel model, IExtensible instance, int tag, DataFormat format, object value)
+ {
+ bool flag = instance == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("instance");
+ }
+ bool flag2 = value == null;
+ if (flag2)
+ {
+ throw new ArgumentNullException("value");
+ }
+ IExtension extensionObject = instance.GetExtensionObject(true);
+ bool flag3 = extensionObject == null;
+ if (flag3)
+ {
+ throw new InvalidOperationException("No extension object available; appended data would be lost.");
+ }
+ bool commit = false;
+ Stream stream = extensionObject.BeginAppend();
+ try
+ {
+ using (ProtoWriter protoWriter = new ProtoWriter(stream, model, null))
+ {
+ model.TrySerializeAuxiliaryType(protoWriter, null, format, tag, value, false);
+ protoWriter.Close();
+ }
+ commit = true;
+ }
+ finally
+ {
+ extensionObject.EndAppend(stream, commit);
+ }
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ExtensibleUtil.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/ExtensibleUtil.cs.meta new file mode 100644 index 00000000..b01930e8 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ExtensibleUtil.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6bc96ccf173fbeb428e12bc9b4771977 +timeCreated: 1611403893 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Helpers.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Helpers.cs new file mode 100644 index 00000000..7d4c3711 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Helpers.cs @@ -0,0 +1,341 @@ +using System;
+using System.Diagnostics;
+using System.Reflection;
+using System.Text;
+
+namespace ProtoBuf
+{
+ internal sealed class Helpers
+ {
+ public static readonly Type[] EmptyTypes = Type.EmptyTypes;
+
+ private Helpers()
+ {
+ }
+
+ public static StringBuilder AppendLine(StringBuilder builder)
+ {
+ return builder.AppendLine();
+ }
+
+ public static bool IsNullOrEmpty(string value)
+ {
+ return value == null || value.Length == 0;
+ }
+
+ [Conditional("DEBUG")]
+ public static void DebugWriteLine(string message, object obj)
+ {
+ string str;
+ try
+ {
+ str = ((obj == null) ? "(null)" : obj.ToString());
+ }
+ catch
+ {
+ str = "(exception)";
+ }
+ Helpers.DebugWriteLine(message + ": " + str);
+ }
+
+ [Conditional("DEBUG")]
+ public static void DebugWriteLine(string message)
+ {
+ Debug.WriteLine(message);
+ }
+
+ [Conditional("TRACE")]
+ public static void TraceWriteLine(string message)
+ {
+ Trace.WriteLine(message);
+ }
+
+ [Conditional("DEBUG")]
+ public static void DebugAssert(bool condition, string message)
+ {
+ bool flag = !condition;
+ if (flag)
+ {
+ Debug.Assert(false, message);
+ }
+ }
+
+ [Conditional("DEBUG")]
+ public static void DebugAssert(bool condition, string message, params object[] args)
+ {
+ bool flag = !condition;
+ if (flag)
+ {
+ Helpers.DebugAssert(false, string.Format(message, args));
+ }
+ }
+
+ [Conditional("DEBUG")]
+ public static void DebugAssert(bool condition)
+ {
+ bool flag = !condition && System.Diagnostics.Debugger.IsAttached;
+ if (flag)
+ {
+ System.Diagnostics.Debugger.Break();
+ }
+ Debug.Assert(condition);
+ }
+
+ public static void Sort(int[] keys, object[] values)
+ {
+ bool flag;
+ do
+ {
+ flag = false;
+ for (int i = 1; i < keys.Length; i++)
+ {
+ bool flag2 = keys[i - 1] > keys[i];
+ if (flag2)
+ {
+ int num = keys[i];
+ keys[i] = keys[i - 1];
+ keys[i - 1] = num;
+ object obj = values[i];
+ values[i] = values[i - 1];
+ values[i - 1] = obj;
+ flag = true;
+ }
+ }
+ }
+ while (flag);
+ }
+
+ public static void BlockCopy(byte[] from, int fromIndex, byte[] to, int toIndex, int count)
+ {
+ Buffer.BlockCopy(from, fromIndex, to, toIndex, count);
+ }
+
+ public static bool IsInfinity(float value)
+ {
+ return float.IsInfinity(value);
+ }
+
+ internal static MethodInfo GetInstanceMethod(Type declaringType, string name)
+ {
+ return declaringType.GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+ }
+
+ internal static MethodInfo GetStaticMethod(Type declaringType, string name)
+ {
+ return declaringType.GetMethod(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
+ }
+
+ internal static MethodInfo GetInstanceMethod(Type declaringType, string name, Type[] types)
+ {
+ bool flag = types == null;
+ if (flag)
+ {
+ types = Helpers.EmptyTypes;
+ }
+ return declaringType.GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, types, null);
+ }
+
+ internal static bool IsSubclassOf(Type type, Type baseClass)
+ {
+ return type.IsSubclassOf(baseClass);
+ }
+
+ public static bool IsInfinity(double value)
+ {
+ return double.IsInfinity(value);
+ }
+
+ public static ProtoTypeCode GetTypeCode(Type type)
+ {
+ TypeCode typeCode = Type.GetTypeCode(type);
+ switch (typeCode)
+ {
+ case TypeCode.Empty:
+ case TypeCode.Boolean:
+ case TypeCode.Char:
+ case TypeCode.SByte:
+ case TypeCode.Byte:
+ case TypeCode.Int16:
+ case TypeCode.UInt16:
+ case TypeCode.Int32:
+ case TypeCode.UInt32:
+ case TypeCode.Int64:
+ case TypeCode.UInt64:
+ case TypeCode.Single:
+ case TypeCode.Double:
+ case TypeCode.Decimal:
+ case TypeCode.DateTime:
+ case TypeCode.String:
+ return (ProtoTypeCode)typeCode;
+ }
+ bool flag = type == typeof(TimeSpan);
+ ProtoTypeCode result;
+ if (flag)
+ {
+ result = ProtoTypeCode.TimeSpan;
+ }
+ else
+ {
+ bool flag2 = type == typeof(Guid);
+ if (flag2)
+ {
+ result = ProtoTypeCode.Guid;
+ }
+ else
+ {
+ bool flag3 = type == typeof(Uri);
+ if (flag3)
+ {
+ result = ProtoTypeCode.Uri;
+ }
+ else
+ {
+ bool flag4 = type == typeof(byte[]);
+ if (flag4)
+ {
+ result = ProtoTypeCode.ByteArray;
+ }
+ else
+ {
+ bool flag5 = type == typeof(Type);
+ if (flag5)
+ {
+ result = ProtoTypeCode.Type;
+ }
+ else
+ {
+ result = ProtoTypeCode.Unknown;
+ }
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ internal static Type GetUnderlyingType(Type type)
+ {
+ return Nullable.GetUnderlyingType(type);
+ }
+
+ internal static bool IsValueType(Type type)
+ {
+ return type.IsValueType;
+ }
+
+ internal static bool IsEnum(Type type)
+ {
+ return type.IsEnum;
+ }
+
+ internal static MethodInfo GetGetMethod(PropertyInfo property, bool nonPublic, bool allowInternal)
+ {
+ bool flag = property == null;
+ MethodInfo result;
+ if (flag)
+ {
+ result = null;
+ }
+ else
+ {
+ MethodInfo methodInfo = property.GetGetMethod(nonPublic);
+ bool flag2 = methodInfo == null && !nonPublic && allowInternal;
+ if (flag2)
+ {
+ methodInfo = property.GetGetMethod(true);
+ bool flag3 = methodInfo == null && !methodInfo.IsAssembly && !methodInfo.IsFamilyOrAssembly;
+ if (flag3)
+ {
+ methodInfo = null;
+ }
+ }
+ result = methodInfo;
+ }
+ return result;
+ }
+
+ internal static MethodInfo GetSetMethod(PropertyInfo property, bool nonPublic, bool allowInternal)
+ {
+ bool flag = property == null;
+ MethodInfo result;
+ if (flag)
+ {
+ result = null;
+ }
+ else
+ {
+ MethodInfo methodInfo = property.GetSetMethod(nonPublic);
+ bool flag2 = methodInfo == null && !nonPublic && allowInternal;
+ if (flag2)
+ {
+ methodInfo = property.GetGetMethod(true);
+ bool flag3 = methodInfo == null && !methodInfo.IsAssembly && !methodInfo.IsFamilyOrAssembly;
+ if (flag3)
+ {
+ methodInfo = null;
+ }
+ }
+ result = methodInfo;
+ }
+ return result;
+ }
+
+ internal static ConstructorInfo GetConstructor(Type type, Type[] parameterTypes, bool nonPublic)
+ {
+ return type.GetConstructor(nonPublic ? (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) : (BindingFlags.Instance | BindingFlags.Public), null, parameterTypes, null);
+ }
+
+ internal static ConstructorInfo[] GetConstructors(Type type, bool nonPublic)
+ {
+ return type.GetConstructors(nonPublic ? (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) : (BindingFlags.Instance | BindingFlags.Public));
+ }
+
+ internal static PropertyInfo GetProperty(Type type, string name, bool nonPublic)
+ {
+ return type.GetProperty(name, nonPublic ? (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) : (BindingFlags.Instance | BindingFlags.Public));
+ }
+
+ internal static object ParseEnum(Type type, string value)
+ {
+ return Enum.Parse(type, value, true);
+ }
+
+ internal static MemberInfo[] GetInstanceFieldsAndProperties(Type type, bool publicOnly)
+ {
+ BindingFlags bindingAttr = publicOnly ? (BindingFlags.Instance | BindingFlags.Public) : (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+ PropertyInfo[] properties = type.GetProperties(bindingAttr);
+ FieldInfo[] fields = type.GetFields(bindingAttr);
+ MemberInfo[] array = new MemberInfo[fields.Length + properties.Length];
+ properties.CopyTo(array, 0);
+ fields.CopyTo(array, properties.Length);
+ return array;
+ }
+
+ internal static Type GetMemberType(MemberInfo member)
+ {
+ MemberTypes memberType = member.MemberType;
+ Type result;
+ if (memberType != MemberTypes.Field)
+ {
+ if (memberType != MemberTypes.Property)
+ {
+ result = null;
+ }
+ else
+ {
+ result = ((PropertyInfo)member).PropertyType;
+ }
+ }
+ else
+ {
+ result = ((FieldInfo)member).FieldType;
+ }
+ return result;
+ }
+
+ internal static bool IsAssignableFrom(Type target, Type type)
+ {
+ return target.IsAssignableFrom(type);
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Helpers.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Helpers.cs.meta new file mode 100644 index 00000000..58025d0d --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Helpers.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2dafd29875705334ea80c76b5cb82b63 +timeCreated: 1611403507 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/IExtensible.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/IExtensible.cs new file mode 100644 index 00000000..941b86a9 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/IExtensible.cs @@ -0,0 +1,9 @@ +using System;
+
+namespace ProtoBuf
+{
+ public interface IExtensible
+ {
+ IExtension GetExtensionObject(bool createIfMissing);
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/IExtensible.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/IExtensible.cs.meta new file mode 100644 index 00000000..dc34ff39 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/IExtensible.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5ff47a5fb05919b45bfddeb18f37939e +timeCreated: 1611403831 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/IExtension.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/IExtension.cs new file mode 100644 index 00000000..001754df --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/IExtension.cs @@ -0,0 +1,18 @@ +using System;
+using System.IO;
+
+namespace ProtoBuf
+{
+ public interface IExtension
+ {
+ Stream BeginAppend();
+
+ void EndAppend(Stream stream, bool commit);
+
+ Stream BeginQuery();
+
+ void EndQuery(Stream stream);
+
+ int GetLength();
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/IExtension.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/IExtension.cs.meta new file mode 100644 index 00000000..60a55cf0 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/IExtension.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 83f33cea356663a419170cd907d6b9ce +timeCreated: 1611404046 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ImplicitFields.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/ImplicitFields.cs new file mode 100644 index 00000000..ca310765 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ImplicitFields.cs @@ -0,0 +1,11 @@ +using System;
+
+namespace ProtoBuf
+{
+ public enum ImplicitFields
+ {
+ None,
+ AllPublic,
+ AllFields
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ImplicitFields.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/ImplicitFields.cs.meta new file mode 100644 index 00000000..19e70a8c --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ImplicitFields.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b9802b45bb8732c479aa537a633885a5 +timeCreated: 1611404410 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/MemberSerializationOptions.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/MemberSerializationOptions.cs new file mode 100644 index 00000000..70b37e60 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/MemberSerializationOptions.cs @@ -0,0 +1,16 @@ +using System;
+
+namespace ProtoBuf
+{
+ [Flags]
+ public enum MemberSerializationOptions
+ {
+ None = 0,
+ Packed = 1,
+ Required = 2,
+ AsReference = 4,
+ DynamicType = 8,
+ OverwriteList = 16,
+ AsReferenceHasValue = 32
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/MemberSerializationOptions.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/MemberSerializationOptions.cs.meta new file mode 100644 index 00000000..a9a95b42 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/MemberSerializationOptions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ae30f2bfd7c00b347acefae14066d26a +timeCreated: 1611404338 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta.meta new file mode 100644 index 00000000..1cfb21e4 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 2b782c6e2c04dd848a0802da8522a8b6 +folderAsset: yes +timeCreated: 1611402943 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/AttributeMap.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/AttributeMap.cs new file mode 100644 index 00000000..4fb2059b --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/AttributeMap.cs @@ -0,0 +1,117 @@ +using System;
+using System.Reflection;
+
+namespace ProtoBuf.Meta
+{
+ internal abstract class AttributeMap
+ {
+ public abstract Type AttributeType { get; }
+
+ public abstract object Target { get; }
+
+ private sealed class ReflectionAttributeMap : AttributeMap
+ {
+ public override object Target
+ {
+ get
+ {
+ return this.attribute;
+ }
+ }
+
+ public override Type AttributeType
+ {
+ get
+ {
+ return this.attribute.GetType();
+ }
+ }
+
+ private readonly Attribute attribute;
+
+ public override bool TryGet(string key, bool publicOnly, out object value)
+ {
+ foreach (MemberInfo memberInfo in Helpers.GetInstanceFieldsAndProperties(this.attribute.GetType(), publicOnly))
+ {
+ bool flag = string.Equals(memberInfo.Name, key, StringComparison.OrdinalIgnoreCase);
+ if (flag)
+ {
+ PropertyInfo propertyInfo = memberInfo as PropertyInfo;
+ bool flag2 = propertyInfo != null;
+ bool result;
+ if (flag2)
+ {
+ value = propertyInfo.GetValue(this.attribute, null);
+ result = true;
+ }
+ else
+ {
+ FieldInfo fieldInfo = memberInfo as FieldInfo;
+ bool flag3 = fieldInfo != null;
+ if (!flag3)
+ {
+ throw new NotSupportedException(memberInfo.GetType().Name);
+ }
+ value = fieldInfo.GetValue(this.attribute);
+ result = true;
+ }
+ return result;
+ }
+ }
+ value = null;
+ return false;
+ }
+
+ public ReflectionAttributeMap(Attribute attribute)
+ {
+ this.attribute = attribute;
+ }
+ }
+
+ [Obsolete("Please use AttributeType instead")]
+ public new Type GetType()
+ {
+ return this.AttributeType;
+ }
+
+ public abstract bool TryGet(string key, bool publicOnly, out object value);
+
+ public bool TryGet(string key, out object value)
+ {
+ return this.TryGet(key, true, out value);
+ }
+
+ public static AttributeMap[] Create(TypeModel model, Type type, bool inherit)
+ {
+ object[] customAttributes = type.GetCustomAttributes(inherit);
+ AttributeMap[] array = new AttributeMap[customAttributes.Length];
+ for (int i = 0; i < customAttributes.Length; i++)
+ {
+ array[i] = new AttributeMap.ReflectionAttributeMap((Attribute)customAttributes[i]);
+ }
+ return array;
+ }
+
+ public static AttributeMap[] Create(TypeModel model, MemberInfo member, bool inherit)
+ {
+ object[] customAttributes = member.GetCustomAttributes(inherit);
+ AttributeMap[] array = new AttributeMap[customAttributes.Length];
+ for (int i = 0; i < customAttributes.Length; i++)
+ {
+ array[i] = new AttributeMap.ReflectionAttributeMap((Attribute)customAttributes[i]);
+ }
+ return array;
+ }
+
+ public static AttributeMap[] Create(TypeModel model, Assembly assembly)
+ {
+ object[] customAttributes = assembly.GetCustomAttributes(false);
+ AttributeMap[] array = new AttributeMap[customAttributes.Length];
+ for (int i = 0; i < customAttributes.Length; i++)
+ {
+ array[i] = new AttributeMap.ReflectionAttributeMap((Attribute)customAttributes[i]);
+ }
+ return array;
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/AttributeMap.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/AttributeMap.cs.meta new file mode 100644 index 00000000..484bca84 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/AttributeMap.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 87e043055f5d7a44eb9f66262b09652e +timeCreated: 1611404081 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/BasicList.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/BasicList.cs new file mode 100644 index 00000000..68acbe62 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/BasicList.cs @@ -0,0 +1,337 @@ +using System;
+using System.Collections;
+
+namespace ProtoBuf.Meta
+{
+ internal class BasicList : IEnumerable
+ {
+ public object this[int index]
+ {
+ get
+ {
+ return this.head[index];
+ }
+ }
+
+ public int Count
+ {
+ get
+ {
+ return this.head.Length;
+ }
+ }
+
+ private static readonly BasicList.Node nil = new BasicList.Node(null, 0);
+
+ protected BasicList.Node head = BasicList.nil;
+
+ public struct NodeEnumerator : IEnumerator
+ {
+ public object Current
+ {
+ get
+ {
+ return this.node[this.position];
+ }
+ }
+
+ private int position;
+
+ private readonly BasicList.Node node;
+
+ internal NodeEnumerator(BasicList.Node node)
+ {
+ this.position = -1;
+ this.node = node;
+ }
+
+ void IEnumerator.Reset()
+ {
+ this.position = -1;
+ }
+
+ public bool MoveNext()
+ {
+ int length = this.node.Length;
+ bool result;
+ if (this.position <= length)
+ {
+ int num = this.position + 1;
+ this.position = num;
+ result = (num < length);
+ }
+ else
+ {
+ result = false;
+ }
+ return result;
+ }
+ }
+
+ internal sealed class Node
+ {
+ public object this[int index]
+ {
+ get
+ {
+ bool flag = index >= 0 && index < this.length;
+ if (flag)
+ {
+ return this.data[index];
+ }
+ throw new ArgumentOutOfRangeException("index");
+ }
+ set
+ {
+ bool flag = index >= 0 && index < this.length;
+ if (flag)
+ {
+ this.data[index] = value;
+ return;
+ }
+ throw new ArgumentOutOfRangeException("index");
+ }
+ }
+
+ public int Length
+ {
+ get
+ {
+ return this.length;
+ }
+ }
+
+ private readonly object[] data;
+
+ private int length;
+
+ internal Node(object[] data, int length)
+ {
+ Helpers.DebugAssert((data == null && length == 0) || (data != null && length > 0 && length <= data.Length));
+ this.data = data;
+ this.length = length;
+ }
+
+ public void RemoveLastWithMutate()
+ {
+ bool flag = this.length == 0;
+ if (flag)
+ {
+ throw new InvalidOperationException();
+ }
+ this.length--;
+ }
+
+ public BasicList.Node Append(object value)
+ {
+ int num = this.length + 1;
+ bool flag = this.data == null;
+ object[] array;
+ if (flag)
+ {
+ array = new object[10];
+ }
+ else
+ {
+ bool flag2 = this.length == this.data.Length;
+ if (flag2)
+ {
+ array = new object[this.data.Length * 2];
+ Array.Copy(this.data, array, this.length);
+ }
+ else
+ {
+ array = this.data;
+ }
+ }
+ array[this.length] = value;
+ return new BasicList.Node(array, num);
+ }
+
+ public BasicList.Node Trim()
+ {
+ bool flag = this.length == 0 || this.length == this.data.Length;
+ BasicList.Node result;
+ if (flag)
+ {
+ result = this;
+ }
+ else
+ {
+ object[] destinationArray = new object[this.length];
+ Array.Copy(this.data, destinationArray, this.length);
+ result = new BasicList.Node(destinationArray, this.length);
+ }
+ return result;
+ }
+
+ internal int IndexOfString(string value)
+ {
+ for (int i = 0; i < this.length; i++)
+ {
+ bool flag = value == (string)this.data[i];
+ if (flag)
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ internal int IndexOfReference(object instance)
+ {
+ for (int i = 0; i < this.length; i++)
+ {
+ bool flag = instance == this.data[i];
+ if (flag)
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ internal int IndexOf(BasicList.MatchPredicate predicate, object ctx)
+ {
+ for (int i = 0; i < this.length; i++)
+ {
+ bool flag = predicate(this.data[i], ctx);
+ if (flag)
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ internal void CopyTo(Array array, int offset)
+ {
+ bool flag = this.length > 0;
+ if (flag)
+ {
+ Array.Copy(this.data, 0, array, offset, this.length);
+ }
+ }
+
+ internal void Clear()
+ {
+ bool flag = this.data != null;
+ if (flag)
+ {
+ Array.Clear(this.data, 0, this.data.Length);
+ }
+ this.length = 0;
+ }
+ }
+
+ internal delegate bool MatchPredicate(object value, object ctx);
+
+ internal sealed class Group
+ {
+ public readonly int First;
+
+ public readonly BasicList Items;
+
+ public Group(int first)
+ {
+ this.First = first;
+ this.Items = new BasicList();
+ }
+ }
+
+ public void CopyTo(Array array, int offset)
+ {
+ this.head.CopyTo(array, offset);
+ }
+
+ public int Add(object value)
+ {
+ return (this.head = this.head.Append(value)).Length - 1;
+ }
+
+ public void Trim()
+ {
+ this.head = this.head.Trim();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return new BasicList.NodeEnumerator(this.head);
+ }
+
+ public BasicList.NodeEnumerator GetEnumerator()
+ {
+ return new BasicList.NodeEnumerator(this.head);
+ }
+
+ public void Clear()
+ {
+ this.head = BasicList.nil;
+ }
+
+ internal int IndexOf(BasicList.MatchPredicate predicate, object ctx)
+ {
+ return this.head.IndexOf(predicate, ctx);
+ }
+
+ internal int IndexOfString(string value)
+ {
+ return this.head.IndexOfString(value);
+ }
+
+ internal int IndexOfReference(object instance)
+ {
+ return this.head.IndexOfReference(instance);
+ }
+
+ internal bool Contains(object value)
+ {
+ foreach (object objA in this)
+ {
+ bool flag = object.Equals(objA, value);
+ if (flag)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ internal static BasicList GetContiguousGroups(int[] keys, object[] values)
+ {
+ bool flag = keys == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("keys");
+ }
+ bool flag2 = values == null;
+ if (flag2)
+ {
+ throw new ArgumentNullException("values");
+ }
+ bool flag3 = values.Length < keys.Length;
+ if (flag3)
+ {
+ throw new ArgumentException("Not all keys are covered by values", "values");
+ }
+ BasicList basicList = new BasicList();
+ BasicList.Group group = null;
+ for (int i = 0; i < keys.Length; i++)
+ {
+ bool flag4 = i == 0 || keys[i] != keys[i - 1];
+ if (flag4)
+ {
+ group = null;
+ }
+ bool flag5 = group == null;
+ if (flag5)
+ {
+ group = new BasicList.Group(keys[i]);
+ basicList.Add(group);
+ }
+ group.Items.Add(values[i]);
+ }
+ return basicList;
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/BasicList.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/BasicList.cs.meta new file mode 100644 index 00000000..de4e1a55 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/BasicList.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6a87ac069938105429795f2d59f09a44 +timeCreated: 1611403888 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/CallbackSet.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/CallbackSet.cs new file mode 100644 index 00000000..d0e7c11a --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/CallbackSet.cs @@ -0,0 +1,160 @@ +using System;
+using System.Reflection;
+
+namespace ProtoBuf.Meta
+{
+ public class CallbackSet
+ {
+ internal MethodInfo this[TypeModel.CallbackType callbackType]
+ {
+ get
+ {
+ MethodInfo result;
+ switch (callbackType)
+ {
+ case TypeModel.CallbackType.BeforeSerialize:
+ result = this.beforeSerialize;
+ break;
+ case TypeModel.CallbackType.AfterSerialize:
+ result = this.afterSerialize;
+ break;
+ case TypeModel.CallbackType.BeforeDeserialize:
+ result = this.beforeDeserialize;
+ break;
+ case TypeModel.CallbackType.AfterDeserialize:
+ result = this.afterDeserialize;
+ break;
+ default:
+ throw new ArgumentException("Callback type not supported: " + callbackType.ToString(), "callbackType");
+ }
+ return result;
+ }
+ }
+
+ public MethodInfo BeforeSerialize
+ {
+ get
+ {
+ return this.beforeSerialize;
+ }
+ set
+ {
+ this.beforeSerialize = this.SanityCheckCallback(this.metaType.Model, value);
+ }
+ }
+
+ public MethodInfo BeforeDeserialize
+ {
+ get
+ {
+ return this.beforeDeserialize;
+ }
+ set
+ {
+ this.beforeDeserialize = this.SanityCheckCallback(this.metaType.Model, value);
+ }
+ }
+
+ public MethodInfo AfterSerialize
+ {
+ get
+ {
+ return this.afterSerialize;
+ }
+ set
+ {
+ this.afterSerialize = this.SanityCheckCallback(this.metaType.Model, value);
+ }
+ }
+
+ public MethodInfo AfterDeserialize
+ {
+ get
+ {
+ return this.afterDeserialize;
+ }
+ set
+ {
+ this.afterDeserialize = this.SanityCheckCallback(this.metaType.Model, value);
+ }
+ }
+
+ public bool NonTrivial
+ {
+ get
+ {
+ return this.beforeSerialize != null || this.beforeDeserialize != null || this.afterSerialize != null || this.afterDeserialize != null;
+ }
+ }
+
+ private readonly MetaType metaType;
+
+ private MethodInfo beforeSerialize;
+
+ private MethodInfo afterSerialize;
+
+ private MethodInfo beforeDeserialize;
+
+ private MethodInfo afterDeserialize;
+
+ internal CallbackSet(MetaType metaType)
+ {
+ bool flag = metaType == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("metaType");
+ }
+ this.metaType = metaType;
+ }
+
+ internal static bool CheckCallbackParameters(TypeModel model, MethodInfo method)
+ {
+ ParameterInfo[] parameters = method.GetParameters();
+ for (int i = 0; i < parameters.Length; i++)
+ {
+ Type parameterType = parameters[i].ParameterType;
+ bool flag = parameterType == model.MapType(typeof(SerializationContext));
+ if (!flag)
+ {
+ bool flag2 = parameterType == model.MapType(typeof(Type));
+ if (!flag2)
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ private MethodInfo SanityCheckCallback(TypeModel model, MethodInfo callback)
+ {
+ this.metaType.ThrowIfFrozen();
+ bool flag = callback == null;
+ MethodInfo result;
+ if (flag)
+ {
+ result = callback;
+ }
+ else
+ {
+ bool isStatic = callback.IsStatic;
+ if (isStatic)
+ {
+ throw new ArgumentException("Callbacks cannot be static", "callback");
+ }
+ bool flag2 = callback.ReturnType != model.MapType(typeof(void)) || !CallbackSet.CheckCallbackParameters(model, callback);
+ if (flag2)
+ {
+ throw CallbackSet.CreateInvalidCallbackSignature(callback);
+ }
+ result = callback;
+ }
+ return result;
+ }
+
+ internal static Exception CreateInvalidCallbackSignature(MethodInfo method)
+ {
+ return new NotSupportedException("Invalid callback signature in " + method.DeclaringType.FullName + "." + method.Name);
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/CallbackSet.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/CallbackSet.cs.meta new file mode 100644 index 00000000..ce94d50b --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/CallbackSet.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7760448d52303f54b8f3541b6ffa032b +timeCreated: 1611403953 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/LockContentedEventArgs.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/LockContentedEventArgs.cs new file mode 100644 index 00000000..f787bb96 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/LockContentedEventArgs.cs @@ -0,0 +1,22 @@ +using System;
+
+namespace ProtoBuf.Meta
+{
+ public sealed class LockContentedEventArgs : EventArgs
+ {
+ public string OwnerStackTrace
+ {
+ get
+ {
+ return this.ownerStackTrace;
+ }
+ }
+
+ private readonly string ownerStackTrace;
+
+ internal LockContentedEventArgs(string ownerStackTrace)
+ {
+ this.ownerStackTrace = ownerStackTrace;
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/LockContentedEventArgs.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/LockContentedEventArgs.cs.meta new file mode 100644 index 00000000..29208e95 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/LockContentedEventArgs.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a2e0f668b28069e42964cccec0290fb9 +timeCreated: 1611404258 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/LockContentedEventHandler.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/LockContentedEventHandler.cs new file mode 100644 index 00000000..fa01dd00 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/LockContentedEventHandler.cs @@ -0,0 +1,6 @@ +using System;
+
+namespace ProtoBuf.Meta
+{
+ public delegate void LockContentedEventHandler(object sender, LockContentedEventArgs args);
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/LockContentedEventHandler.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/LockContentedEventHandler.cs.meta new file mode 100644 index 00000000..abafbdb1 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/LockContentedEventHandler.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4bf547271692e3a4db4f971055c6f2a1 +timeCreated: 1611403689 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/MetaType.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/MetaType.cs new file mode 100644 index 00000000..e65ee2f3 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/MetaType.cs @@ -0,0 +1,2327 @@ +using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Text;
+using ProtoBuf.Serializers;
+
+namespace ProtoBuf.Meta
+{
+ public class MetaType : ISerializerProxy
+ {
+ IProtoSerializer ISerializerProxy.Serializer
+ {
+ get
+ {
+ return this.Serializer;
+ }
+ }
+
+ public MetaType BaseType
+ {
+ get
+ {
+ return this.baseType;
+ }
+ }
+
+ internal TypeModel Model
+ {
+ get
+ {
+ return this.model;
+ }
+ }
+
+ public bool IncludeSerializerMethod
+ {
+ get
+ {
+ return !this.HasFlag(8);
+ }
+ set
+ {
+ this.SetFlag(8, !value, true);
+ }
+ }
+
+ public bool AsReferenceDefault
+ {
+ get
+ {
+ return this.HasFlag(32);
+ }
+ set
+ {
+ this.SetFlag(32, value, true);
+ }
+ }
+
+ public bool HasCallbacks
+ {
+ get
+ {
+ return this.callbacks != null && this.callbacks.NonTrivial;
+ }
+ }
+
+ public bool HasSubtypes
+ {
+ get
+ {
+ return this.subTypes != null && this.subTypes.Count != 0;
+ }
+ }
+
+ public CallbackSet Callbacks
+ {
+ get
+ {
+ bool flag = this.callbacks == null;
+ if (flag)
+ {
+ this.callbacks = new CallbackSet(this);
+ }
+ return this.callbacks;
+ }
+ }
+
+ private bool IsValueType
+ {
+ get
+ {
+ return this.type.IsValueType;
+ }
+ }
+
+ public string Name
+ {
+ get
+ {
+ return this.name;
+ }
+ set
+ {
+ this.ThrowIfFrozen();
+ this.name = value;
+ }
+ }
+
+ public Type Type
+ {
+ get
+ {
+ return this.type;
+ }
+ }
+
+ internal IProtoTypeSerializer Serializer
+ {
+ get
+ {
+ bool flag = this.serializer == null;
+ if (flag)
+ {
+ int opaqueToken = 0;
+ try
+ {
+ this.model.TakeLock(ref opaqueToken);
+ bool flag2 = this.serializer == null;
+ if (flag2)
+ {
+ this.SetFlag(4, true, false);
+ this.serializer = this.BuildSerializer();
+ }
+ }
+ finally
+ {
+ this.model.ReleaseLock(opaqueToken);
+ }
+ }
+ return this.serializer;
+ }
+ }
+
+ internal bool IsList
+ {
+ get
+ {
+ Type type = this.IgnoreListHandling ? null : TypeModel.GetListItemType(this.model, this.type);
+ return type != null;
+ }
+ }
+
+ public bool UseConstructor
+ {
+ get
+ {
+ return !this.HasFlag(16);
+ }
+ set
+ {
+ this.SetFlag(16, !value, true);
+ }
+ }
+
+ public Type ConstructType
+ {
+ get
+ {
+ return this.constructType;
+ }
+ set
+ {
+ this.ThrowIfFrozen();
+ this.constructType = value;
+ }
+ }
+
+ public ValueMember this[int fieldNumber]
+ {
+ get
+ {
+ foreach (object obj in this.fields)
+ {
+ ValueMember valueMember = (ValueMember)obj;
+ bool flag = valueMember.FieldNumber == fieldNumber;
+ if (flag)
+ {
+ return valueMember;
+ }
+ }
+ return null;
+ }
+ }
+
+ public ValueMember this[MemberInfo member]
+ {
+ get
+ {
+ bool flag = member == null;
+ ValueMember result;
+ if (flag)
+ {
+ result = null;
+ }
+ else
+ {
+ foreach (object obj in this.fields)
+ {
+ ValueMember valueMember = (ValueMember)obj;
+ bool flag2 = valueMember.Member == member;
+ if (flag2)
+ {
+ return valueMember;
+ }
+ }
+ result = null;
+ }
+ return result;
+ }
+ }
+
+ public bool EnumPassthru
+ {
+ get
+ {
+ return this.HasFlag(2);
+ }
+ set
+ {
+ this.SetFlag(2, value, true);
+ }
+ }
+
+ public bool IgnoreListHandling
+ {
+ get
+ {
+ return this.HasFlag(128);
+ }
+ set
+ {
+ this.SetFlag(128, value, true);
+ }
+ }
+
+ internal bool Pending
+ {
+ get
+ {
+ return this.HasFlag(1);
+ }
+ set
+ {
+ this.SetFlag(1, value, false);
+ }
+ }
+
+ internal IEnumerable Fields
+ {
+ get
+ {
+ return this.fields;
+ }
+ }
+
+ internal bool IsAutoTuple
+ {
+ get
+ {
+ return this.HasFlag(64);
+ }
+ }
+
+ private MetaType baseType;
+
+ private BasicList subTypes;
+
+ internal static readonly Type ienumerable = typeof(IEnumerable);
+
+ private CallbackSet callbacks;
+
+ private string name;
+
+ private MethodInfo factory;
+
+ private readonly RuntimeTypeModel model;
+
+ private readonly Type type;
+
+ private IProtoTypeSerializer serializer;
+
+ private Type constructType;
+
+ private Type surrogate;
+
+ private readonly BasicList fields = new BasicList();
+
+ private const byte OPTIONS_Pending = 1;
+
+ private const byte OPTIONS_EnumPassThru = 2;
+
+ private const byte OPTIONS_Frozen = 4;
+
+ private const byte OPTIONS_PrivateOnApi = 8;
+
+ private const byte OPTIONS_SkipConstructor = 16;
+
+ private const byte OPTIONS_AsReferenceDefault = 32;
+
+ private const byte OPTIONS_AutoTuple = 64;
+
+ private const byte OPTIONS_IgnoreListHandling = 128;
+
+ private volatile byte flags;
+
+ internal sealed class Comparer : IComparer, IComparer<MetaType>
+ {
+ public static readonly MetaType.Comparer Default = new MetaType.Comparer();
+
+ public int Compare(object x, object y)
+ {
+ return this.Compare(x as MetaType, y as MetaType);
+ }
+
+ public int Compare(MetaType x, MetaType y)
+ {
+ bool flag = x == y;
+ int result;
+ if (flag)
+ {
+ result = 0;
+ }
+ else
+ {
+ bool flag2 = x == null;
+ if (flag2)
+ {
+ result = -1;
+ }
+ else
+ {
+ bool flag3 = y == null;
+ if (flag3)
+ {
+ result = 1;
+ }
+ else
+ {
+ result = string.Compare(x.GetSchemaTypeName(), y.GetSchemaTypeName(), StringComparison.Ordinal);
+ }
+ }
+ }
+ return result;
+ }
+ }
+
+ [Flags]
+ internal enum AttributeFamily
+ {
+ None = 0,
+ ProtoBuf = 1,
+ DataContractSerialier = 2,
+ XmlSerializer = 4,
+ AutoTuple = 8
+ }
+
+ public override string ToString()
+ {
+ return this.type.ToString();
+ }
+
+ private bool IsValidSubType(Type subType)
+ {
+ return this.type.IsAssignableFrom(subType);
+ }
+
+ public MetaType AddSubType(int fieldNumber, Type derivedType)
+ {
+ return this.AddSubType(fieldNumber, derivedType, DataFormat.Default);
+ }
+
+ public MetaType AddSubType(int fieldNumber, Type derivedType, DataFormat dataFormat)
+ {
+ bool flag = derivedType == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("derivedType");
+ }
+ bool flag2 = fieldNumber < 1;
+ if (flag2)
+ {
+ throw new ArgumentOutOfRangeException("fieldNumber");
+ }
+ bool flag3 = (!this.type.IsClass && !this.type.IsInterface) || this.type.IsSealed;
+ if (flag3)
+ {
+ throw new InvalidOperationException("Sub-types can only be added to non-sealed classes");
+ }
+ bool flag4 = !this.IsValidSubType(derivedType);
+ if (flag4)
+ {
+ throw new ArgumentException(derivedType.Name + " is not a valid sub-type of " + this.type.Name, "derivedType");
+ }
+ MetaType metaType = this.model[derivedType];
+ this.ThrowIfFrozen();
+ metaType.ThrowIfFrozen();
+ SubType value = new SubType(fieldNumber, metaType, dataFormat);
+ this.ThrowIfFrozen();
+ metaType.SetBaseType(this);
+ bool flag5 = this.subTypes == null;
+ if (flag5)
+ {
+ this.subTypes = new BasicList();
+ }
+ this.subTypes.Add(value);
+ return this;
+ }
+
+ private void SetBaseType(MetaType baseType)
+ {
+ bool flag = baseType == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("baseType");
+ }
+ bool flag2 = this.baseType == baseType;
+ if (!flag2)
+ {
+ bool flag3 = this.baseType != null;
+ if (flag3)
+ {
+ throw new InvalidOperationException("A type can only participate in one inheritance hierarchy");
+ }
+ for (MetaType metaType = baseType; metaType != null; metaType = metaType.baseType)
+ {
+ bool flag4 = metaType == this;
+ if (flag4)
+ {
+ throw new InvalidOperationException("Cyclic inheritance is not allowed");
+ }
+ }
+ this.baseType = baseType;
+ }
+ }
+
+ public MetaType SetCallbacks(MethodInfo beforeSerialize, MethodInfo afterSerialize, MethodInfo beforeDeserialize, MethodInfo afterDeserialize)
+ {
+ CallbackSet callbackSet = this.Callbacks;
+ callbackSet.BeforeSerialize = beforeSerialize;
+ callbackSet.AfterSerialize = afterSerialize;
+ callbackSet.BeforeDeserialize = beforeDeserialize;
+ callbackSet.AfterDeserialize = afterDeserialize;
+ return this;
+ }
+
+ public MetaType SetCallbacks(string beforeSerialize, string afterSerialize, string beforeDeserialize, string afterDeserialize)
+ {
+ bool isValueType = this.IsValueType;
+ if (isValueType)
+ {
+ throw new InvalidOperationException();
+ }
+ CallbackSet callbackSet = this.Callbacks;
+ callbackSet.BeforeSerialize = this.ResolveMethod(beforeSerialize, true);
+ callbackSet.AfterSerialize = this.ResolveMethod(afterSerialize, true);
+ callbackSet.BeforeDeserialize = this.ResolveMethod(beforeDeserialize, true);
+ callbackSet.AfterDeserialize = this.ResolveMethod(afterDeserialize, true);
+ return this;
+ }
+
+ internal string GetSchemaTypeName()
+ {
+ bool flag = this.surrogate != null;
+ string result;
+ if (flag)
+ {
+ result = this.model[this.surrogate].GetSchemaTypeName();
+ }
+ else
+ {
+ bool flag2 = !Helpers.IsNullOrEmpty(this.name);
+ if (flag2)
+ {
+ result = this.name;
+ }
+ else
+ {
+ string text = this.type.Name;
+ bool isGenericType = this.type.IsGenericType;
+ if (isGenericType)
+ {
+ StringBuilder stringBuilder = new StringBuilder(text);
+ int num = text.IndexOf('`');
+ bool flag3 = num >= 0;
+ if (flag3)
+ {
+ stringBuilder.Length = num;
+ }
+ foreach (Type type in this.type.GetGenericArguments())
+ {
+ stringBuilder.Append('_');
+ Type type2 = type;
+ int key = this.model.GetKey(ref type2);
+ MetaType metaType = null;
+ bool flag4 = key >= 0 && (metaType = this.model[type2]) != null && metaType.surrogate == null;
+ if (flag4)
+ {
+ stringBuilder.Append(metaType.GetSchemaTypeName());
+ }
+ else
+ {
+ stringBuilder.Append(type2.Name);
+ }
+ }
+ result = stringBuilder.ToString();
+ }
+ else
+ {
+ result = text;
+ }
+ }
+ }
+ return result;
+ }
+
+ public MetaType SetFactory(MethodInfo factory)
+ {
+ this.model.VerifyFactory(factory, this.type);
+ this.ThrowIfFrozen();
+ this.factory = factory;
+ return this;
+ }
+
+ public MetaType SetFactory(string factory)
+ {
+ return this.SetFactory(this.ResolveMethod(factory, false));
+ }
+
+ private MethodInfo ResolveMethod(string name, bool instance)
+ {
+ bool flag = Helpers.IsNullOrEmpty(name);
+ MethodInfo result;
+ if (flag)
+ {
+ result = null;
+ }
+ else
+ {
+ result = (instance ? Helpers.GetInstanceMethod(this.type, name) : Helpers.GetStaticMethod(this.type, name));
+ }
+ return result;
+ }
+
+ internal static Exception InbuiltType(Type type)
+ {
+ return new ArgumentException("Data of this type has inbuilt behaviour, and cannot be added to a model in this way: " + type.FullName);
+ }
+
+ internal MetaType(RuntimeTypeModel model, Type type, MethodInfo factory)
+ {
+ this.factory = factory;
+ bool flag = model == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("model");
+ }
+ bool flag2 = type == null;
+ if (flag2)
+ {
+ throw new ArgumentNullException("type");
+ }
+ IProtoSerializer protoSerializer = model.TryGetBasicTypeSerializer(type);
+ bool flag3 = protoSerializer != null;
+ if (flag3)
+ {
+ throw MetaType.InbuiltType(type);
+ }
+ this.type = type;
+ this.model = model;
+ bool flag4 = Helpers.IsEnum(type);
+ if (flag4)
+ {
+ this.EnumPassthru = type.IsDefined(model.MapType(typeof(FlagsAttribute)), false);
+ }
+ }
+
+ protected internal void ThrowIfFrozen()
+ {
+ bool flag = (this.flags & 4) > 0;
+ if (flag)
+ {
+ throw new InvalidOperationException("The type cannot be changed once a serializer has been generated for " + this.type.FullName);
+ }
+ }
+
+ private IProtoTypeSerializer BuildSerializer()
+ {
+ bool flag = Helpers.IsEnum(this.type);
+ IProtoTypeSerializer result;
+ if (flag)
+ {
+ result = new TagDecorator(1, WireType.Variant, false, new EnumSerializer(this.type, this.GetEnumMap()));
+ }
+ else
+ {
+ Type type = this.IgnoreListHandling ? null : TypeModel.GetListItemType(this.model, this.type);
+ bool flag2 = type != null;
+ if (flag2)
+ {
+ bool flag3 = this.surrogate != null;
+ if (flag3)
+ {
+ throw new ArgumentException("Repeated data (a list, collection, etc) has inbuilt behaviour and cannot use a surrogate");
+ }
+ bool flag4 = this.subTypes != null && this.subTypes.Count != 0;
+ if (flag4)
+ {
+ throw new ArgumentException("Repeated data (a list, collection, etc) has inbuilt behaviour and cannot be subclassed");
+ }
+ Type defaultType = null;
+ MetaType.ResolveListTypes(this.model, this.type, ref type, ref defaultType);
+ ValueMember valueMember = new ValueMember(this.model, 1, this.type, type, defaultType, DataFormat.Default);
+ result = new TypeSerializer(this.model, this.type, new int[]
+ {
+ 1
+ }, new IProtoSerializer[]
+ {
+ valueMember.Serializer
+ }, null, true, true, null, this.constructType, this.factory);
+ }
+ else
+ {
+ bool flag5 = this.surrogate != null;
+ if (flag5)
+ {
+ MetaType metaType = this.model[this.surrogate];
+ MetaType metaType2;
+ while ((metaType2 = metaType.baseType) != null)
+ {
+ metaType = metaType2;
+ }
+ result = new SurrogateSerializer(this.model, this.type, this.surrogate, metaType.Serializer);
+ }
+ else
+ {
+ bool isAutoTuple = this.IsAutoTuple;
+ if (isAutoTuple)
+ {
+ MemberInfo[] members;
+ ConstructorInfo constructorInfo = MetaType.ResolveTupleConstructor(this.type, out members);
+ bool flag6 = constructorInfo == null;
+ if (flag6)
+ {
+ throw new InvalidOperationException();
+ }
+ result = new TupleSerializer(this.model, constructorInfo, members);
+ }
+ else
+ {
+ this.fields.Trim();
+ int count = this.fields.Count;
+ int num = (this.subTypes == null) ? 0 : this.subTypes.Count;
+ int[] array = new int[count + num];
+ IProtoSerializer[] array2 = new IProtoSerializer[count + num];
+ int num2 = 0;
+ bool flag7 = num != 0;
+ if (flag7)
+ {
+ foreach (object obj in this.subTypes)
+ {
+ SubType subType = (SubType)obj;
+ bool flag8 = !subType.DerivedType.IgnoreListHandling && this.model.MapType(MetaType.ienumerable).IsAssignableFrom(subType.DerivedType.Type);
+ if (flag8)
+ {
+ throw new ArgumentException("Repeated data (a list, collection, etc) has inbuilt behaviour and cannot be used as a subclass");
+ }
+ array[num2] = subType.FieldNumber;
+ array2[num2++] = subType.Serializer;
+ }
+ }
+ bool flag9 = count != 0;
+ if (flag9)
+ {
+ foreach (object obj2 in this.fields)
+ {
+ ValueMember valueMember2 = (ValueMember)obj2;
+ array[num2] = valueMember2.FieldNumber;
+ array2[num2++] = valueMember2.Serializer;
+ }
+ }
+ BasicList basicList = null;
+ for (MetaType metaType3 = this.BaseType; metaType3 != null; metaType3 = metaType3.BaseType)
+ {
+ MethodInfo methodInfo = metaType3.HasCallbacks ? metaType3.Callbacks.BeforeDeserialize : null;
+ bool flag10 = methodInfo != null;
+ if (flag10)
+ {
+ bool flag11 = basicList == null;
+ if (flag11)
+ {
+ basicList = new BasicList();
+ }
+ basicList.Add(methodInfo);
+ }
+ }
+ MethodInfo[] array3 = null;
+ bool flag12 = basicList != null;
+ if (flag12)
+ {
+ array3 = new MethodInfo[basicList.Count];
+ basicList.CopyTo(array3, 0);
+ Array.Reverse(array3);
+ }
+ result = new TypeSerializer(this.model, this.type, array, array2, array3, this.baseType == null, this.UseConstructor, this.callbacks, this.constructType, this.factory);
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ private static Type GetBaseType(MetaType type)
+ {
+ return type.type.BaseType;
+ }
+
+ internal static bool GetAsReferenceDefault(RuntimeTypeModel model, Type type)
+ {
+ bool flag = type == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("type");
+ }
+ bool flag2 = Helpers.IsEnum(type);
+ bool result;
+ if (flag2)
+ {
+ result = false;
+ }
+ else
+ {
+ AttributeMap[] array = AttributeMap.Create(model, type, false);
+ for (int i = 0; i < array.Length; i++)
+ {
+ bool flag3 = array[i].AttributeType.FullName == "ProtoBuf.ProtoContractAttribute";
+ if (flag3)
+ {
+ object obj;
+ bool flag4 = array[i].TryGet("AsReferenceDefault", out obj);
+ if (flag4)
+ {
+ return (bool)obj;
+ }
+ }
+ }
+ result = false;
+ }
+ return result;
+ }
+
+ internal void ApplyDefaultBehaviour()
+ {
+ Type type = MetaType.GetBaseType(this);
+ bool flag = type != null && this.model.FindWithoutAdd(type) == null && MetaType.GetContractFamily(this.model, type, null) > MetaType.AttributeFamily.None;
+ if (flag)
+ {
+ this.model.FindOrAddAuto(type, true, false, false);
+ }
+ AttributeMap[] array = AttributeMap.Create(this.model, this.type, false);
+ MetaType.AttributeFamily attributeFamily = MetaType.GetContractFamily(this.model, this.type, array);
+ bool flag2 = attributeFamily == MetaType.AttributeFamily.AutoTuple;
+ if (flag2)
+ {
+ this.SetFlag(64, true, true);
+ }
+ bool flag3 = !this.EnumPassthru && Helpers.IsEnum(this.type);
+ bool flag4 = attributeFamily == MetaType.AttributeFamily.None && !flag3;
+ if (!flag4)
+ {
+ BasicList basicList = null;
+ BasicList basicList2 = null;
+ int dataMemberOffset = 0;
+ int num = 1;
+ bool flag5 = this.model.InferTagFromNameDefault;
+ ImplicitFields implicitFields = ImplicitFields.None;
+ string text = null;
+ foreach (AttributeMap attributeMap in array)
+ {
+ string fullName = attributeMap.AttributeType.FullName;
+ bool flag6 = !flag3 && fullName == "ProtoBuf.ProtoIncludeAttribute";
+ object obj = null;
+ if (flag6)
+ {
+ int fieldNumber = 0;
+ bool flag7 = attributeMap.TryGet("tag", out obj);
+ if (flag7)
+ {
+ fieldNumber = (int)obj;
+ }
+ DataFormat dataFormat = DataFormat.Default;
+ bool flag8 = attributeMap.TryGet("DataFormat", out obj);
+ if (flag8)
+ {
+ dataFormat = (DataFormat)((int)obj);
+ }
+ Type type2 = null;
+ try
+ {
+ bool flag9 = attributeMap.TryGet("knownTypeName", out obj);
+ if (flag9)
+ {
+ type2 = this.model.GetType((string)obj, this.type.Assembly);
+ }
+ else
+ {
+ bool flag10 = attributeMap.TryGet("knownType", out obj);
+ if (flag10)
+ {
+ type2 = (Type)obj;
+ }
+ }
+ }
+ catch (Exception innerException)
+ {
+ throw new InvalidOperationException("Unable to resolve sub-type of: " + this.type.FullName, innerException);
+ }
+ bool flag11 = type2 == null;
+ if (flag11)
+ {
+ throw new InvalidOperationException("Unable to resolve sub-type of: " + this.type.FullName);
+ }
+ bool flag12 = this.IsValidSubType(type2);
+ if (flag12)
+ {
+ this.AddSubType(fieldNumber, type2, dataFormat);
+ }
+ }
+ bool flag13 = fullName == "ProtoBuf.ProtoPartialIgnoreAttribute";
+ if (flag13)
+ {
+ bool flag14 = attributeMap.TryGet("MemberName", out obj) && obj != null;
+ if (flag14)
+ {
+ bool flag15 = basicList == null;
+ if (flag15)
+ {
+ basicList = new BasicList();
+ }
+ basicList.Add((string)obj);
+ }
+ }
+ bool flag16 = !flag3 && fullName == "ProtoBuf.ProtoPartialMemberAttribute";
+ if (flag16)
+ {
+ bool flag17 = basicList2 == null;
+ if (flag17)
+ {
+ basicList2 = new BasicList();
+ }
+ basicList2.Add(attributeMap);
+ }
+ bool flag18 = fullName == "ProtoBuf.ProtoContractAttribute";
+ if (flag18)
+ {
+ bool flag19 = attributeMap.TryGet("Name", out obj);
+ if (flag19)
+ {
+ text = (string)obj;
+ }
+ bool flag20 = Helpers.IsEnum(this.type);
+ if (flag20)
+ {
+ bool flag21 = attributeMap.TryGet("EnumPassthruHasValue", false, out obj) && (bool)obj;
+ if (flag21)
+ {
+ bool flag22 = attributeMap.TryGet("EnumPassthru", out obj);
+ if (flag22)
+ {
+ this.EnumPassthru = (bool)obj;
+ bool enumPassthru = this.EnumPassthru;
+ if (enumPassthru)
+ {
+ flag3 = false;
+ }
+ }
+ }
+ }
+ else
+ {
+ bool flag23 = attributeMap.TryGet("DataMemberOffset", out obj);
+ if (flag23)
+ {
+ dataMemberOffset = (int)obj;
+ }
+ bool flag24 = attributeMap.TryGet("InferTagFromNameHasValue", false, out obj) && (bool)obj;
+ if (flag24)
+ {
+ bool flag25 = attributeMap.TryGet("InferTagFromName", out obj);
+ if (flag25)
+ {
+ flag5 = (bool)obj;
+ }
+ }
+ bool flag26 = attributeMap.TryGet("ImplicitFields", out obj) && obj != null;
+ if (flag26)
+ {
+ implicitFields = (ImplicitFields)((int)obj);
+ }
+ bool flag27 = attributeMap.TryGet("SkipConstructor", out obj);
+ if (flag27)
+ {
+ this.UseConstructor = !(bool)obj;
+ }
+ bool flag28 = attributeMap.TryGet("IgnoreListHandling", out obj);
+ if (flag28)
+ {
+ this.IgnoreListHandling = (bool)obj;
+ }
+ bool flag29 = attributeMap.TryGet("AsReferenceDefault", out obj);
+ if (flag29)
+ {
+ this.AsReferenceDefault = (bool)obj;
+ }
+ bool flag30 = attributeMap.TryGet("ImplicitFirstTag", out obj) && (int)obj > 0;
+ if (flag30)
+ {
+ num = (int)obj;
+ }
+ }
+ }
+ bool flag31 = fullName == "System.Runtime.Serialization.DataContractAttribute";
+ if (flag31)
+ {
+ bool flag32 = text == null && attributeMap.TryGet("Name", out obj);
+ if (flag32)
+ {
+ text = (string)obj;
+ }
+ }
+ bool flag33 = fullName == "System.Xml.Serialization.XmlTypeAttribute";
+ if (flag33)
+ {
+ bool flag34 = text == null && attributeMap.TryGet("TypeName", out obj);
+ if (flag34)
+ {
+ text = (string)obj;
+ }
+ }
+ }
+ bool flag35 = !Helpers.IsNullOrEmpty(text);
+ if (flag35)
+ {
+ this.Name = text;
+ }
+ bool flag36 = implicitFields > ImplicitFields.None;
+ if (flag36)
+ {
+ attributeFamily &= MetaType.AttributeFamily.ProtoBuf;
+ }
+ MethodInfo[] array2 = null;
+ BasicList basicList3 = new BasicList();
+ MemberInfo[] members = this.type.GetMembers(flag3 ? (BindingFlags.Static | BindingFlags.Public) : (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic));
+ foreach (MemberInfo memberInfo in members)
+ {
+ bool flag37 = memberInfo.DeclaringType != this.type;
+ if (!flag37)
+ {
+ bool flag38 = !ProtoBuf.Serializer.isSkipProtoIgnore;
+ if (flag38)
+ {
+ bool flag39 = memberInfo.IsDefined(this.model.MapType(typeof(ProtoIgnoreAttribute)), true);
+ if (flag39)
+ {
+ goto IL_756;
+ }
+ }
+ bool flag40 = basicList != null && basicList.Contains(memberInfo.Name);
+ if (!flag40)
+ {
+ bool flag41 = false;
+ PropertyInfo propertyInfo;
+ bool flag42 = (propertyInfo = (memberInfo as PropertyInfo)) != null;
+ if (flag42)
+ {
+ bool flag43 = flag3;
+ if (!flag43)
+ {
+ Type type3 = propertyInfo.PropertyType;
+ bool isPublic = Helpers.GetGetMethod(propertyInfo, false, false) != null;
+ bool isField = false;
+ MetaType.ApplyDefaultBehaviour_AddMembers(this.model, attributeFamily, flag3, basicList2, dataMemberOffset, flag5, implicitFields, basicList3, memberInfo, ref flag41, isPublic, isField, ref type3);
+ }
+ }
+ else
+ {
+ FieldInfo fieldInfo;
+ bool flag44 = (fieldInfo = (memberInfo as FieldInfo)) != null;
+ if (flag44)
+ {
+ Type type3 = fieldInfo.FieldType;
+ bool isPublic = fieldInfo.IsPublic;
+ bool isField = true;
+ bool flag45 = flag3 && !fieldInfo.IsStatic;
+ if (!flag45)
+ {
+ MetaType.ApplyDefaultBehaviour_AddMembers(this.model, attributeFamily, flag3, basicList2, dataMemberOffset, flag5, implicitFields, basicList3, memberInfo, ref flag41, isPublic, isField, ref type3);
+ }
+ }
+ else
+ {
+ MethodInfo methodInfo;
+ bool flag46 = (methodInfo = (memberInfo as MethodInfo)) != null;
+ if (flag46)
+ {
+ bool flag47 = flag3;
+ if (!flag47)
+ {
+ AttributeMap[] array4 = AttributeMap.Create(this.model, methodInfo, false);
+ bool flag48 = array4 != null && array4.Length != 0;
+ if (flag48)
+ {
+ MetaType.CheckForCallback(methodInfo, array4, "ProtoBuf.ProtoBeforeSerializationAttribute", ref array2, 0);
+ MetaType.CheckForCallback(methodInfo, array4, "ProtoBuf.ProtoAfterSerializationAttribute", ref array2, 1);
+ MetaType.CheckForCallback(methodInfo, array4, "ProtoBuf.ProtoBeforeDeserializationAttribute", ref array2, 2);
+ MetaType.CheckForCallback(methodInfo, array4, "ProtoBuf.ProtoAfterDeserializationAttribute", ref array2, 3);
+ MetaType.CheckForCallback(methodInfo, array4, "System.Runtime.Serialization.OnSerializingAttribute", ref array2, 4);
+ MetaType.CheckForCallback(methodInfo, array4, "System.Runtime.Serialization.OnSerializedAttribute", ref array2, 5);
+ MetaType.CheckForCallback(methodInfo, array4, "System.Runtime.Serialization.OnDeserializingAttribute", ref array2, 6);
+ MetaType.CheckForCallback(methodInfo, array4, "System.Runtime.Serialization.OnDeserializedAttribute", ref array2, 7);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ IL_756:;
+ }
+ ProtoMemberAttribute[] array5 = new ProtoMemberAttribute[basicList3.Count];
+ basicList3.CopyTo(array5, 0);
+ bool flag49 = flag5 || implicitFields > ImplicitFields.None;
+ if (flag49)
+ {
+ Array.Sort<ProtoMemberAttribute>(array5);
+ int num2 = num;
+ foreach (ProtoMemberAttribute protoMemberAttribute in array5)
+ {
+ bool flag50 = !protoMemberAttribute.TagIsPinned;
+ if (flag50)
+ {
+ protoMemberAttribute.Rebase(num2++);
+ }
+ }
+ }
+ foreach (ProtoMemberAttribute normalizedAttribute in array5)
+ {
+ ValueMember valueMember = this.ApplyDefaultBehaviour(flag3, normalizedAttribute);
+ bool flag51 = valueMember != null;
+ if (flag51)
+ {
+ this.Add(valueMember);
+ }
+ }
+ bool flag52 = array2 != null;
+ if (flag52)
+ {
+ this.SetCallbacks(MetaType.Coalesce(array2, 0, 4), MetaType.Coalesce(array2, 1, 5), MetaType.Coalesce(array2, 2, 6), MetaType.Coalesce(array2, 3, 7));
+ }
+ }
+ }
+
+ private static void ApplyDefaultBehaviour_AddMembers(TypeModel model, MetaType.AttributeFamily family, bool isEnum, BasicList partialMembers, int dataMemberOffset, bool inferTagByName, ImplicitFields implicitMode, BasicList members, MemberInfo member, ref bool forced, bool isPublic, bool isField, ref Type effectiveType)
+ {
+ if (implicitMode != ImplicitFields.AllPublic)
+ {
+ if (implicitMode == ImplicitFields.AllFields)
+ {
+ if (isField)
+ {
+ forced = true;
+ }
+ }
+ }
+ else if (isPublic)
+ {
+ forced = true;
+ }
+ bool flag = effectiveType.IsSubclassOf(model.MapType(typeof(Delegate)));
+ if (flag)
+ {
+ effectiveType = null;
+ }
+ bool flag2 = effectiveType != null;
+ if (flag2)
+ {
+ ProtoMemberAttribute protoMemberAttribute = MetaType.NormalizeProtoMember(model, member, family, forced, isEnum, partialMembers, dataMemberOffset, inferTagByName);
+ bool flag3 = protoMemberAttribute != null;
+ if (flag3)
+ {
+ members.Add(protoMemberAttribute);
+ }
+ }
+ }
+
+ private static MethodInfo Coalesce(MethodInfo[] arr, int x, int y)
+ {
+ MethodInfo methodInfo = arr[x];
+ bool flag = methodInfo == null;
+ if (flag)
+ {
+ methodInfo = arr[y];
+ }
+ return methodInfo;
+ }
+
+ internal static MetaType.AttributeFamily GetContractFamily(RuntimeTypeModel model, Type type, AttributeMap[] attributes)
+ {
+ MetaType.AttributeFamily attributeFamily = MetaType.AttributeFamily.None;
+ bool flag = attributes == null;
+ if (flag)
+ {
+ attributes = AttributeMap.Create(model, type, false);
+ }
+ for (int i = 0; i < attributes.Length; i++)
+ {
+ string fullName = attributes[i].AttributeType.FullName;
+ if (!(fullName == "ProtoBuf.ProtoContractAttribute"))
+ {
+ if (!(fullName == "System.Xml.Serialization.XmlTypeAttribute"))
+ {
+ if (fullName == "System.Runtime.Serialization.DataContractAttribute")
+ {
+ bool flag2 = !model.AutoAddProtoContractTypesOnly;
+ if (flag2)
+ {
+ attributeFamily |= MetaType.AttributeFamily.DataContractSerialier;
+ }
+ }
+ }
+ else
+ {
+ bool flag3 = !model.AutoAddProtoContractTypesOnly;
+ if (flag3)
+ {
+ attributeFamily |= MetaType.AttributeFamily.XmlSerializer;
+ }
+ }
+ }
+ else
+ {
+ bool flag4 = false;
+ MetaType.GetFieldBoolean(ref flag4, attributes[i], "UseProtoMembersOnly");
+ bool flag5 = flag4;
+ if (flag5)
+ {
+ return MetaType.AttributeFamily.ProtoBuf;
+ }
+ attributeFamily |= MetaType.AttributeFamily.ProtoBuf;
+ }
+ }
+ bool flag6 = attributeFamily == MetaType.AttributeFamily.None;
+ if (flag6)
+ {
+ MemberInfo[] array;
+ bool flag7 = MetaType.ResolveTupleConstructor(type, out array) != null;
+ if (flag7)
+ {
+ attributeFamily |= MetaType.AttributeFamily.AutoTuple;
+ }
+ }
+ return attributeFamily;
+ }
+
+ internal static ConstructorInfo ResolveTupleConstructor(Type type, out MemberInfo[] mappedMembers)
+ {
+ mappedMembers = null;
+ bool flag = type == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("type");
+ }
+ bool isAbstract = type.IsAbstract;
+ ConstructorInfo result;
+ if (isAbstract)
+ {
+ result = null;
+ }
+ else
+ {
+ ConstructorInfo[] constructors = Helpers.GetConstructors(type, false);
+ bool flag2 = constructors.Length == 0 || (constructors.Length == 1 && constructors[0].GetParameters().Length == 0);
+ if (flag2)
+ {
+ result = null;
+ }
+ else
+ {
+ MemberInfo[] instanceFieldsAndProperties = Helpers.GetInstanceFieldsAndProperties(type, true);
+ BasicList basicList = new BasicList();
+ for (int i = 0; i < instanceFieldsAndProperties.Length; i++)
+ {
+ PropertyInfo propertyInfo = instanceFieldsAndProperties[i] as PropertyInfo;
+ bool flag3 = propertyInfo != null;
+ if (flag3)
+ {
+ bool flag4 = !propertyInfo.CanRead;
+ if (flag4)
+ {
+ return null;
+ }
+ bool flag5 = propertyInfo.CanWrite && Helpers.GetSetMethod(propertyInfo, false, false) != null;
+ if (flag5)
+ {
+ return null;
+ }
+ basicList.Add(propertyInfo);
+ }
+ else
+ {
+ FieldInfo fieldInfo = instanceFieldsAndProperties[i] as FieldInfo;
+ bool flag6 = fieldInfo != null;
+ if (flag6)
+ {
+ bool flag7 = !fieldInfo.IsInitOnly;
+ if (flag7)
+ {
+ return null;
+ }
+ basicList.Add(fieldInfo);
+ }
+ }
+ }
+ bool flag8 = basicList.Count == 0;
+ if (flag8)
+ {
+ result = null;
+ }
+ else
+ {
+ MemberInfo[] array = new MemberInfo[basicList.Count];
+ basicList.CopyTo(array, 0);
+ int[] array2 = new int[array.Length];
+ int num = 0;
+ ConstructorInfo constructorInfo = null;
+ mappedMembers = new MemberInfo[array2.Length];
+ for (int j = 0; j < constructors.Length; j++)
+ {
+ ParameterInfo[] parameters = constructors[j].GetParameters();
+ bool flag9 = parameters.Length != array.Length;
+ if (!flag9)
+ {
+ for (int k = 0; k < array2.Length; k++)
+ {
+ array2[k] = -1;
+ }
+ for (int l = 0; l < parameters.Length; l++)
+ {
+ string b = parameters[l].Name.ToLower();
+ for (int m = 0; m < array.Length; m++)
+ {
+ bool flag10 = array[m].Name.ToLower() != b;
+ if (!flag10)
+ {
+ Type memberType = Helpers.GetMemberType(array[m]);
+ bool flag11 = memberType != parameters[l].ParameterType;
+ if (!flag11)
+ {
+ array2[l] = m;
+ }
+ }
+ }
+ }
+ bool flag12 = false;
+ for (int n = 0; n < array2.Length; n++)
+ {
+ bool flag13 = array2[n] < 0;
+ if (flag13)
+ {
+ flag12 = true;
+ break;
+ }
+ mappedMembers[n] = array[array2[n]];
+ }
+ bool flag14 = flag12;
+ if (!flag14)
+ {
+ num++;
+ constructorInfo = constructors[j];
+ }
+ }
+ }
+ result = ((num == 1) ? constructorInfo : null);
+ }
+ }
+ }
+ return result;
+ }
+
+ private static void CheckForCallback(MethodInfo method, AttributeMap[] attributes, string callbackTypeName, ref MethodInfo[] callbacks, int index)
+ {
+ for (int i = 0; i < attributes.Length; i++)
+ {
+ bool flag = attributes[i].AttributeType.FullName == callbackTypeName;
+ if (flag)
+ {
+ bool flag2 = callbacks == null;
+ if (flag2)
+ {
+ callbacks = new MethodInfo[8];
+ }
+ else
+ {
+ bool flag3 = callbacks[index] != null;
+ if (flag3)
+ {
+ Type reflectedType = method.ReflectedType;
+ throw new ProtoException("Duplicate " + callbackTypeName + " callbacks on " + reflectedType.FullName);
+ }
+ }
+ callbacks[index] = method;
+ }
+ }
+ }
+
+ private static bool HasFamily(MetaType.AttributeFamily value, MetaType.AttributeFamily required)
+ {
+ return (value & required) == required;
+ }
+
+ private static ProtoMemberAttribute NormalizeProtoMember(TypeModel model, MemberInfo member, MetaType.AttributeFamily family, bool forced, bool isEnum, BasicList partialMembers, int dataMemberOffset, bool inferByTagName)
+ {
+ bool flag = member == null || (family == MetaType.AttributeFamily.None && !isEnum);
+ ProtoMemberAttribute result;
+ if (flag)
+ {
+ result = null;
+ }
+ else
+ {
+ int num = int.MinValue;
+ int num2 = inferByTagName ? -1 : 1;
+ string text = null;
+ bool isPacked = false;
+ bool flag2 = false;
+ bool flag3 = false;
+ bool isRequired = false;
+ bool asReference = false;
+ bool flag4 = false;
+ bool dynamicType = false;
+ bool tagIsPinned = false;
+ bool overwriteList = false;
+ DataFormat dataFormat = DataFormat.Default;
+ if (isEnum)
+ {
+ forced = true;
+ }
+ AttributeMap[] attribs = AttributeMap.Create(model, member, true);
+ if (isEnum)
+ {
+ AttributeMap attribute = MetaType.GetAttribute(attribs, "ProtoBuf.ProtoIgnoreAttribute");
+ bool flag5 = attribute != null;
+ if (flag5)
+ {
+ flag2 = true;
+ }
+ else
+ {
+ attribute = MetaType.GetAttribute(attribs, "ProtoBuf.ProtoEnumAttribute");
+ num = Convert.ToInt32(((FieldInfo)member).GetRawConstantValue());
+ bool flag6 = attribute != null;
+ if (flag6)
+ {
+ MetaType.GetFieldName(ref text, attribute, "Name");
+ bool flag7 = (bool)Helpers.GetInstanceMethod(attribute.AttributeType, "HasValue").Invoke(attribute.Target, null);
+ if (flag7)
+ {
+ object obj;
+ bool flag8 = attribute.TryGet("Value", out obj);
+ if (flag8)
+ {
+ num = (int)obj;
+ }
+ }
+ }
+ }
+ flag3 = true;
+ }
+ bool flag9 = !flag2 && !flag3;
+ if (flag9)
+ {
+ AttributeMap attribute = MetaType.GetAttribute(attribs, "ProtoBuf.ProtoMemberAttribute");
+ MetaType.GetIgnore(ref flag2, attribute, attribs, "ProtoBuf.ProtoIgnoreAttribute");
+ bool flag10 = !flag2 && attribute != null;
+ if (flag10)
+ {
+ MetaType.GetFieldNumber(ref num, attribute, "Tag");
+ MetaType.GetFieldName(ref text, attribute, "Name");
+ MetaType.GetFieldBoolean(ref isRequired, attribute, "IsRequired");
+ MetaType.GetFieldBoolean(ref isPacked, attribute, "IsPacked");
+ MetaType.GetFieldBoolean(ref overwriteList, attribute, "OverwriteList");
+ MetaType.GetDataFormat(ref dataFormat, attribute, "DataFormat");
+ MetaType.GetFieldBoolean(ref flag4, attribute, "AsReferenceHasValue", false);
+ bool flag11 = flag4;
+ if (flag11)
+ {
+ flag4 = MetaType.GetFieldBoolean(ref asReference, attribute, "AsReference", true);
+ }
+ MetaType.GetFieldBoolean(ref dynamicType, attribute, "DynamicType");
+ tagIsPinned = (flag3 = (num > 0));
+ }
+ bool flag12 = !flag3 && partialMembers != null;
+ if (flag12)
+ {
+ foreach (object obj2 in partialMembers)
+ {
+ AttributeMap attributeMap = (AttributeMap)obj2;
+ object obj3;
+ bool flag13 = attributeMap.TryGet("MemberName", out obj3) && (string)obj3 == member.Name;
+ if (flag13)
+ {
+ MetaType.GetFieldNumber(ref num, attributeMap, "Tag");
+ MetaType.GetFieldName(ref text, attributeMap, "Name");
+ MetaType.GetFieldBoolean(ref isRequired, attributeMap, "IsRequired");
+ MetaType.GetFieldBoolean(ref isPacked, attributeMap, "IsPacked");
+ MetaType.GetFieldBoolean(ref overwriteList, attribute, "OverwriteList");
+ MetaType.GetDataFormat(ref dataFormat, attributeMap, "DataFormat");
+ MetaType.GetFieldBoolean(ref flag4, attribute, "AsReferenceHasValue", false);
+ bool flag14 = flag4;
+ if (flag14)
+ {
+ flag4 = MetaType.GetFieldBoolean(ref asReference, attributeMap, "AsReference", true);
+ }
+ MetaType.GetFieldBoolean(ref dynamicType, attributeMap, "DynamicType");
+ bool flag15;
+ flag3 = (flag15 = (tagIsPinned = (num > 0)));
+ if (flag15)
+ {
+ break;
+ }
+ }
+ }
+ }
+ }
+ bool flag16 = !flag2 && !flag3 && MetaType.HasFamily(family, MetaType.AttributeFamily.DataContractSerialier);
+ if (flag16)
+ {
+ AttributeMap attribute = MetaType.GetAttribute(attribs, "System.Runtime.Serialization.DataMemberAttribute");
+ bool flag17 = attribute != null;
+ if (flag17)
+ {
+ MetaType.GetFieldNumber(ref num, attribute, "Order");
+ MetaType.GetFieldName(ref text, attribute, "Name");
+ MetaType.GetFieldBoolean(ref isRequired, attribute, "IsRequired");
+ flag3 = (num >= num2);
+ bool flag18 = flag3;
+ if (flag18)
+ {
+ num += dataMemberOffset;
+ }
+ }
+ }
+ bool flag19 = !flag2 && !flag3 && MetaType.HasFamily(family, MetaType.AttributeFamily.XmlSerializer);
+ if (flag19)
+ {
+ AttributeMap attribute = MetaType.GetAttribute(attribs, "System.Xml.Serialization.XmlElementAttribute");
+ bool flag20 = attribute == null;
+ if (flag20)
+ {
+ attribute = MetaType.GetAttribute(attribs, "System.Xml.Serialization.XmlArrayAttribute");
+ }
+ MetaType.GetIgnore(ref flag2, attribute, attribs, "System.Xml.Serialization.XmlIgnoreAttribute");
+ bool flag21 = attribute != null && !flag2;
+ if (flag21)
+ {
+ MetaType.GetFieldNumber(ref num, attribute, "Order");
+ MetaType.GetFieldName(ref text, attribute, "ElementName");
+ flag3 = (num >= num2);
+ }
+ }
+ bool flag22 = !flag2 && !flag3;
+ if (flag22)
+ {
+ bool flag23 = MetaType.GetAttribute(attribs, "System.NonSerializedAttribute") != null;
+ if (flag23)
+ {
+ flag2 = true;
+ }
+ }
+ bool flag24 = flag2 || (num < num2 && !forced);
+ if (flag24)
+ {
+ result = null;
+ }
+ else
+ {
+ result = new ProtoMemberAttribute(num, forced || inferByTagName)
+ {
+ AsReference = asReference,
+ AsReferenceHasValue = flag4,
+ DataFormat = dataFormat,
+ DynamicType = dynamicType,
+ IsPacked = isPacked,
+ OverwriteList = overwriteList,
+ IsRequired = isRequired,
+ Name = (Helpers.IsNullOrEmpty(text) ? member.Name : text),
+ Member = member,
+ TagIsPinned = tagIsPinned
+ };
+ }
+ }
+ return result;
+ }
+
+ private ValueMember ApplyDefaultBehaviour(bool isEnum, ProtoMemberAttribute normalizedAttribute)
+ {
+ MemberInfo member= null;
+ bool flag = normalizedAttribute == null || (member = normalizedAttribute.Member) == null;
+ ValueMember result;
+ if (flag)
+ {
+ result = null;
+ }
+ else
+ {
+ Type memberType = Helpers.GetMemberType(member);
+ Type type = null;
+ Type defaultType = null;
+ MetaType.ResolveListTypes(this.model, memberType, ref type, ref defaultType);
+ bool flag2 = type != null;
+ if (flag2)
+ {
+ int num = this.model.FindOrAddAuto(memberType, false, true, false);
+ bool flag3 = num >= 0 && this.model[memberType].IgnoreListHandling;
+ if (flag3)
+ {
+ type = null;
+ defaultType = null;
+ }
+ }
+ AttributeMap[] attribs = AttributeMap.Create(this.model, member, true);
+ object defaultValue = null;
+ bool useImplicitZeroDefaults = this.model.UseImplicitZeroDefaults;
+ if (useImplicitZeroDefaults)
+ {
+ ProtoTypeCode typeCode = Helpers.GetTypeCode(memberType);
+ switch (typeCode)
+ {
+ case ProtoTypeCode.Boolean:
+ defaultValue = false;
+ break;
+ case ProtoTypeCode.Char:
+ defaultValue = '\0';
+ break;
+ case ProtoTypeCode.SByte:
+ defaultValue = 0;
+ break;
+ case ProtoTypeCode.Byte:
+ defaultValue = 0;
+ break;
+ case ProtoTypeCode.Int16:
+ defaultValue = 0;
+ break;
+ case ProtoTypeCode.UInt16:
+ defaultValue = 0;
+ break;
+ case ProtoTypeCode.Int32:
+ defaultValue = 0;
+ break;
+ case ProtoTypeCode.UInt32:
+ defaultValue = 0u;
+ break;
+ case ProtoTypeCode.Int64:
+ defaultValue = 0L;
+ break;
+ case ProtoTypeCode.UInt64:
+ defaultValue = 0UL;
+ break;
+ case ProtoTypeCode.Single:
+ defaultValue = 0f;
+ break;
+ case ProtoTypeCode.Double:
+ defaultValue = 0.0;
+ break;
+ case ProtoTypeCode.Decimal:
+ defaultValue = 0m;
+ break;
+ default:
+ if (typeCode != ProtoTypeCode.TimeSpan)
+ {
+ if (typeCode == ProtoTypeCode.Guid)
+ {
+ defaultValue = Guid.Empty;
+ }
+ }
+ else
+ {
+ defaultValue = TimeSpan.Zero;
+ }
+ break;
+ }
+ }
+ AttributeMap attribute;
+ bool flag4 = (attribute = MetaType.GetAttribute(attribs, "System.ComponentModel.DefaultValueAttribute")) != null;
+ if (flag4)
+ {
+ object obj;
+ bool flag5 = attribute.TryGet("Value", out obj);
+ if (flag5)
+ {
+ defaultValue = obj;
+ }
+ }
+ ValueMember valueMember = (isEnum || normalizedAttribute.Tag > 0) ? new ValueMember(this.model, this.type, normalizedAttribute.Tag, member, memberType, type, defaultType, normalizedAttribute.DataFormat, defaultValue) : null;
+ bool flag6 = valueMember != null;
+ if (flag6)
+ {
+ Type declaringType = this.type;
+ PropertyInfo propertyInfo = Helpers.GetProperty(declaringType, member.Name + "Specified", true);
+ MethodInfo getMethod = Helpers.GetGetMethod(propertyInfo, true, true);
+ bool flag7 = getMethod == null || getMethod.IsStatic;
+ if (flag7)
+ {
+ propertyInfo = null;
+ }
+ bool flag8 = propertyInfo != null;
+ if (flag8)
+ {
+ valueMember.SetSpecified(getMethod, Helpers.GetSetMethod(propertyInfo, true, true));
+ }
+ else
+ {
+ MethodInfo instanceMethod = Helpers.GetInstanceMethod(declaringType, "ShouldSerialize" + member.Name, Helpers.EmptyTypes);
+ bool flag9 = instanceMethod != null && instanceMethod.ReturnType == this.model.MapType(typeof(bool));
+ if (flag9)
+ {
+ valueMember.SetSpecified(instanceMethod, null);
+ }
+ }
+ bool flag10 = !Helpers.IsNullOrEmpty(normalizedAttribute.Name);
+ if (flag10)
+ {
+ valueMember.SetName(normalizedAttribute.Name);
+ }
+ valueMember.IsPacked = normalizedAttribute.IsPacked;
+ valueMember.IsRequired = normalizedAttribute.IsRequired;
+ valueMember.OverwriteList = normalizedAttribute.OverwriteList;
+ bool asReferenceHasValue = normalizedAttribute.AsReferenceHasValue;
+ if (asReferenceHasValue)
+ {
+ valueMember.AsReference = normalizedAttribute.AsReference;
+ }
+ valueMember.DynamicType = normalizedAttribute.DynamicType;
+ }
+ result = valueMember;
+ }
+ return result;
+ }
+
+ private static void GetDataFormat(ref DataFormat value, AttributeMap attrib, string memberName)
+ {
+ bool flag = attrib == null || value > DataFormat.Default;
+ if (!flag)
+ {
+ object obj;
+ bool flag2 = attrib.TryGet(memberName, out obj) && obj != null;
+ if (flag2)
+ {
+ value = (DataFormat)obj;
+ }
+ }
+ }
+
+ private static void GetIgnore(ref bool ignore, AttributeMap attrib, AttributeMap[] attribs, string fullName)
+ {
+ bool flag = ignore || attrib == null;
+ if (!flag)
+ {
+ ignore = (MetaType.GetAttribute(attribs, fullName) != null);
+ }
+ }
+
+ private static void GetFieldBoolean(ref bool value, AttributeMap attrib, string memberName)
+ {
+ MetaType.GetFieldBoolean(ref value, attrib, memberName, true);
+ }
+
+ private static bool GetFieldBoolean(ref bool value, AttributeMap attrib, string memberName, bool publicOnly)
+ {
+ bool flag = attrib == null;
+ bool result;
+ if (flag)
+ {
+ result = false;
+ }
+ else
+ {
+ bool flag2 = value;
+ if (flag2)
+ {
+ result = true;
+ }
+ else
+ {
+ object obj;
+ bool flag3 = attrib.TryGet(memberName, publicOnly, out obj) && obj != null;
+ if (flag3)
+ {
+ value = (bool)obj;
+ result = true;
+ }
+ else
+ {
+ result = false;
+ }
+ }
+ }
+ return result;
+ }
+
+ private static void GetFieldNumber(ref int value, AttributeMap attrib, string memberName)
+ {
+ bool flag = attrib == null || value > 0;
+ if (!flag)
+ {
+ object obj;
+ bool flag2 = attrib.TryGet(memberName, out obj) && obj != null;
+ if (flag2)
+ {
+ value = (int)obj;
+ }
+ }
+ }
+
+ private static void GetFieldName(ref string name, AttributeMap attrib, string memberName)
+ {
+ bool flag = attrib == null || !Helpers.IsNullOrEmpty(name);
+ if (!flag)
+ {
+ object obj;
+ bool flag2 = attrib.TryGet(memberName, out obj) && obj != null;
+ if (flag2)
+ {
+ name = (string)obj;
+ }
+ }
+ }
+
+ private static AttributeMap GetAttribute(AttributeMap[] attribs, string fullName)
+ {
+ foreach (AttributeMap attributeMap in attribs)
+ {
+ bool flag = attributeMap != null && attributeMap.AttributeType.FullName == fullName;
+ if (flag)
+ {
+ return attributeMap;
+ }
+ }
+ return null;
+ }
+
+ public MetaType Add(int fieldNumber, string memberName)
+ {
+ this.AddField(fieldNumber, memberName, null, null, null);
+ return this;
+ }
+
+ public ValueMember AddField(int fieldNumber, string memberName)
+ {
+ return this.AddField(fieldNumber, memberName, null, null, null);
+ }
+
+ public MetaType Add(string memberName)
+ {
+ this.Add(this.GetNextFieldNumber(), memberName);
+ return this;
+ }
+
+ public void SetSurrogate(Type surrogateType)
+ {
+ bool flag = surrogateType == this.type;
+ if (flag)
+ {
+ surrogateType = null;
+ }
+ bool flag2 = surrogateType != null;
+ if (flag2)
+ {
+ bool flag3 = surrogateType != null && Helpers.IsAssignableFrom(this.model.MapType(typeof(IEnumerable)), surrogateType);
+ if (flag3)
+ {
+ throw new ArgumentException("Repeated data (a list, collection, etc) has inbuilt behaviour and cannot be used as a surrogate");
+ }
+ }
+ this.ThrowIfFrozen();
+ this.surrogate = surrogateType;
+ }
+
+ internal MetaType GetSurrogateOrSelf()
+ {
+ bool flag = this.surrogate != null;
+ MetaType result;
+ if (flag)
+ {
+ result = this.model[this.surrogate];
+ }
+ else
+ {
+ result = this;
+ }
+ return result;
+ }
+
+ internal MetaType GetSurrogateOrBaseOrSelf(bool deep)
+ {
+ bool flag = this.surrogate != null;
+ MetaType result;
+ if (flag)
+ {
+ result = this.model[this.surrogate];
+ }
+ else
+ {
+ MetaType metaType = this.baseType;
+ bool flag2 = metaType != null;
+ if (flag2)
+ {
+ if (deep)
+ {
+ MetaType metaType2;
+ do
+ {
+ metaType2 = metaType;
+ metaType = metaType.baseType;
+ }
+ while (metaType != null);
+ result = metaType2;
+ }
+ else
+ {
+ result = metaType;
+ }
+ }
+ else
+ {
+ result = this;
+ }
+ }
+ return result;
+ }
+
+ private int GetNextFieldNumber()
+ {
+ int num = 0;
+ foreach (object obj in this.fields)
+ {
+ ValueMember valueMember = (ValueMember)obj;
+ bool flag = valueMember.FieldNumber > num;
+ if (flag)
+ {
+ num = valueMember.FieldNumber;
+ }
+ }
+ bool flag2 = this.subTypes != null;
+ if (flag2)
+ {
+ foreach (object obj2 in this.subTypes)
+ {
+ SubType subType = (SubType)obj2;
+ bool flag3 = subType.FieldNumber > num;
+ if (flag3)
+ {
+ num = subType.FieldNumber;
+ }
+ }
+ }
+ return num + 1;
+ }
+
+ public MetaType Add(params string[] memberNames)
+ {
+ bool flag = memberNames == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("memberNames");
+ }
+ int nextFieldNumber = this.GetNextFieldNumber();
+ for (int i = 0; i < memberNames.Length; i++)
+ {
+ this.Add(nextFieldNumber++, memberNames[i]);
+ }
+ return this;
+ }
+
+ public MetaType Add(int fieldNumber, string memberName, object defaultValue)
+ {
+ this.AddField(fieldNumber, memberName, null, null, defaultValue);
+ return this;
+ }
+
+ public MetaType Add(int fieldNumber, string memberName, Type itemType, Type defaultType)
+ {
+ this.AddField(fieldNumber, memberName, itemType, defaultType, null);
+ return this;
+ }
+
+ public ValueMember AddField(int fieldNumber, string memberName, Type itemType, Type defaultType)
+ {
+ return this.AddField(fieldNumber, memberName, itemType, defaultType, null);
+ }
+
+ private ValueMember AddField(int fieldNumber, string memberName, Type itemType, Type defaultType, object defaultValue)
+ {
+ MemberInfo memberInfo = null;
+ MemberInfo[] member = this.type.GetMember(memberName, Helpers.IsEnum(this.type) ? (BindingFlags.Static | BindingFlags.Public) : (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic));
+ bool flag = member != null && member.Length == 1;
+ if (flag)
+ {
+ memberInfo = member[0];
+ }
+ bool flag2 = memberInfo == null;
+ if (flag2)
+ {
+ throw new ArgumentException("Unable to determine member: " + memberName, "memberName");
+ }
+ MemberTypes memberType = memberInfo.MemberType;
+ Type memberType2;
+ if (memberType != MemberTypes.Field)
+ {
+ if (memberType != MemberTypes.Property)
+ {
+ throw new NotSupportedException(memberInfo.MemberType.ToString());
+ }
+ memberType2 = ((PropertyInfo)memberInfo).PropertyType;
+ }
+ else
+ {
+ memberType2 = ((FieldInfo)memberInfo).FieldType;
+ }
+ MetaType.ResolveListTypes(this.model, memberType2, ref itemType, ref defaultType);
+ ValueMember valueMember = new ValueMember(this.model, this.type, fieldNumber, memberInfo, memberType2, itemType, defaultType, DataFormat.Default, defaultValue);
+ this.Add(valueMember);
+ return valueMember;
+ }
+
+ internal static void ResolveListTypes(TypeModel model, Type type, ref Type itemType, ref Type defaultType)
+ {
+ bool flag = type == null;
+ if (!flag)
+ {
+ bool isArray = type.IsArray;
+ if (isArray)
+ {
+ bool flag2 = type.GetArrayRank() != 1;
+ if (flag2)
+ {
+ throw new NotSupportedException("Multi-dimension arrays are supported");
+ }
+ itemType = type.GetElementType();
+ bool flag3 = itemType == model.MapType(typeof(byte));
+ if (flag3)
+ {
+ Type type2;
+ itemType = (type2 = null);
+ defaultType = type2;
+ }
+ else
+ {
+ defaultType = type;
+ }
+ }
+ bool flag4 = itemType == null;
+ if (flag4)
+ {
+ itemType = TypeModel.GetListItemType(model, type);
+ }
+ bool flag5 = itemType != null;
+ if (flag5)
+ {
+ Type type3 = null;
+ Type type4 = null;
+ MetaType.ResolveListTypes(model, itemType, ref type3, ref type4);
+ bool flag6 = type3 != null;
+ if (flag6)
+ {
+ throw TypeModel.CreateNestedListsNotSupported();
+ }
+ }
+ bool flag7 = itemType != null && defaultType == null;
+ if (flag7)
+ {
+ bool flag8 = type.IsClass && !type.IsAbstract && Helpers.GetConstructor(type, Helpers.EmptyTypes, true) != null;
+ if (flag8)
+ {
+ defaultType = type;
+ }
+ bool flag9 = defaultType == null;
+ if (flag9)
+ {
+ bool isInterface = type.IsInterface;
+ if (isInterface)
+ {
+ Type[] genericArguments = null;
+ bool flag10 = type.IsGenericType && type.GetGenericTypeDefinition() == model.MapType(typeof(IDictionary<, >)) && itemType == model.MapType(typeof(KeyValuePair<, >)).MakeGenericType(genericArguments = type.GetGenericArguments());
+ if (flag10)
+ {
+ defaultType = model.MapType(typeof(Dictionary<, >)).MakeGenericType(genericArguments);
+ }
+ else
+ {
+ defaultType = model.MapType(typeof(List<>)).MakeGenericType(new Type[]
+ {
+ itemType
+ });
+ }
+ }
+ }
+ bool flag11 = defaultType != null && !Helpers.IsAssignableFrom(type, defaultType);
+ if (flag11)
+ {
+ defaultType = null;
+ }
+ }
+ }
+ }
+
+ private void Add(ValueMember member)
+ {
+ int opaqueToken = 0;
+ try
+ {
+ this.model.TakeLock(ref opaqueToken);
+ this.ThrowIfFrozen();
+ this.fields.Add(member);
+ }
+ finally
+ {
+ this.model.ReleaseLock(opaqueToken);
+ }
+ }
+
+ public ValueMember[] GetFields()
+ {
+ ValueMember[] array = new ValueMember[this.fields.Count];
+ this.fields.CopyTo(array, 0);
+ Array.Sort<ValueMember>(array, ValueMember.Comparer.Default);
+ return array;
+ }
+
+ public SubType[] GetSubtypes()
+ {
+ bool flag = this.subTypes == null || this.subTypes.Count == 0;
+ SubType[] result;
+ if (flag)
+ {
+ result = new SubType[0];
+ }
+ else
+ {
+ SubType[] array = new SubType[this.subTypes.Count];
+ this.subTypes.CopyTo(array, 0);
+ Array.Sort<SubType>(array, SubType.Comparer.Default);
+ result = array;
+ }
+ return result;
+ }
+
+ internal bool IsDefined(int fieldNumber)
+ {
+ foreach (object obj in this.fields)
+ {
+ ValueMember valueMember = (ValueMember)obj;
+ bool flag = valueMember.FieldNumber == fieldNumber;
+ if (flag)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ internal int GetKey(bool demand, bool getBaseKey)
+ {
+ return this.model.GetKey(this.type, demand, getBaseKey);
+ }
+
+ internal EnumSerializer.EnumPair[] GetEnumMap()
+ {
+ bool flag = this.HasFlag(2);
+ EnumSerializer.EnumPair[] result;
+ if (flag)
+ {
+ result = null;
+ }
+ else
+ {
+ EnumSerializer.EnumPair[] array = new EnumSerializer.EnumPair[this.fields.Count];
+ for (int i = 0; i < array.Length; i++)
+ {
+ ValueMember valueMember = (ValueMember)this.fields[i];
+ int fieldNumber = valueMember.FieldNumber;
+ object rawEnumValue = valueMember.GetRawEnumValue();
+ array[i] = new EnumSerializer.EnumPair(fieldNumber, rawEnumValue, valueMember.MemberType);
+ }
+ result = array;
+ }
+ return result;
+ }
+
+ private bool HasFlag(byte flag)
+ {
+ return (this.flags & flag) == flag;
+ }
+
+ private void SetFlag(byte flag, bool value, bool throwIfFrozen)
+ {
+ bool flag2 = throwIfFrozen && this.HasFlag(flag) != value;
+ if (flag2)
+ {
+ this.ThrowIfFrozen();
+ }
+ if (value)
+ {
+ this.flags |= flag;
+ }
+ else
+ {
+ this.flags &= (byte)~flag;
+ }
+ }
+
+ internal static MetaType GetRootType(MetaType source)
+ {
+ MetaType result;
+ while (source.serializer != null)
+ {
+ MetaType metaType = source.baseType;
+ bool flag = metaType == null;
+ if (flag)
+ {
+ result = source;
+ return result;
+ }
+ source = metaType;
+ }
+ RuntimeTypeModel runtimeTypeModel = source.model;
+ int opaqueToken = 0;
+ try
+ {
+ runtimeTypeModel.TakeLock(ref opaqueToken);
+ MetaType metaType2;
+ while ((metaType2 = source.baseType) != null)
+ {
+ source = metaType2;
+ }
+ result = source;
+ }
+ finally
+ {
+ runtimeTypeModel.ReleaseLock(opaqueToken);
+ }
+ return result;
+ }
+
+ internal bool IsPrepared()
+ {
+ return false;
+ }
+
+ internal static StringBuilder NewLine(StringBuilder builder, int indent)
+ {
+ return Helpers.AppendLine(builder).Append(' ', indent * 3);
+ }
+
+ internal void WriteSchema(StringBuilder builder, int indent, ref bool requiresBclImport)
+ {
+ bool flag = this.surrogate != null;
+ if (!flag)
+ {
+ ValueMember[] array = new ValueMember[this.fields.Count];
+ this.fields.CopyTo(array, 0);
+ Array.Sort<ValueMember>(array, ValueMember.Comparer.Default);
+ bool isList = this.IsList;
+ if (isList)
+ {
+ string schemaTypeName = this.model.GetSchemaTypeName(TypeModel.GetListItemType(this.model, this.type), DataFormat.Default, false, false, ref requiresBclImport);
+ MetaType.NewLine(builder, indent).Append("message ").Append(this.GetSchemaTypeName()).Append(" {");
+ MetaType.NewLine(builder, indent + 1).Append("repeated ").Append(schemaTypeName).Append(" items = 1;");
+ MetaType.NewLine(builder, indent).Append('}');
+ }
+ else
+ {
+ bool isAutoTuple = this.IsAutoTuple;
+ if (isAutoTuple)
+ {
+ MemberInfo[] array2;
+ bool flag2 = MetaType.ResolveTupleConstructor(this.type, out array2) != null;
+ if (flag2)
+ {
+ MetaType.NewLine(builder, indent).Append("message ").Append(this.GetSchemaTypeName()).Append(" {");
+ for (int i = 0; i < array2.Length; i++)
+ {
+ bool flag3 = array2[i] is PropertyInfo;
+ Type effectiveType;
+ if (flag3)
+ {
+ effectiveType = ((PropertyInfo)array2[i]).PropertyType;
+ }
+ else
+ {
+ bool flag4 = array2[i] is FieldInfo;
+ if (!flag4)
+ {
+ throw new NotSupportedException("Unknown member type: " + array2[i].GetType().Name);
+ }
+ effectiveType = ((FieldInfo)array2[i]).FieldType;
+ }
+ MetaType.NewLine(builder, indent + 1).Append("optional ").Append(this.model.GetSchemaTypeName(effectiveType, DataFormat.Default, false, false, ref requiresBclImport).Replace('.', '_')).Append(' ').Append(array2[i].Name).Append(" = ").Append(i + 1).Append(';');
+ }
+ MetaType.NewLine(builder, indent).Append('}');
+ }
+ }
+ else
+ {
+ bool flag5 = Helpers.IsEnum(this.type);
+ if (flag5)
+ {
+ MetaType.NewLine(builder, indent).Append("enum ").Append(this.GetSchemaTypeName()).Append(" {");
+ bool flag6 = array.Length == 0 && this.EnumPassthru;
+ if (flag6)
+ {
+ bool flag7 = this.type.IsDefined(this.model.MapType(typeof(FlagsAttribute)), false);
+ if (flag7)
+ {
+ MetaType.NewLine(builder, indent + 1).Append("// this is a composite/flags enumeration");
+ }
+ else
+ {
+ MetaType.NewLine(builder, indent + 1).Append("// this enumeration will be passed as a raw value");
+ }
+ foreach (FieldInfo fieldInfo in this.type.GetFields())
+ {
+ bool flag8 = fieldInfo.IsStatic && fieldInfo.IsLiteral;
+ if (flag8)
+ {
+ object rawConstantValue = fieldInfo.GetRawConstantValue();
+ MetaType.NewLine(builder, indent + 1).Append(fieldInfo.Name).Append(" = ").Append(rawConstantValue).Append(";");
+ }
+ }
+ }
+ else
+ {
+ foreach (ValueMember valueMember in array)
+ {
+ MetaType.NewLine(builder, indent + 1).Append(valueMember.Name).Append(" = ").Append(valueMember.FieldNumber).Append(';');
+ }
+ }
+ MetaType.NewLine(builder, indent).Append('}');
+ }
+ else
+ {
+ MetaType.NewLine(builder, indent).Append("message ").Append(this.GetSchemaTypeName()).Append(" {");
+ foreach (ValueMember valueMember2 in array)
+ {
+ string value = (valueMember2.ItemType != null) ? "repeated" : (valueMember2.IsRequired ? "required" : "optional");
+ MetaType.NewLine(builder, indent + 1).Append(value).Append(' ');
+ bool flag9 = valueMember2.DataFormat == DataFormat.Group;
+ if (flag9)
+ {
+ builder.Append("group ");
+ }
+ string schemaTypeName2 = valueMember2.GetSchemaTypeName(true, ref requiresBclImport);
+ builder.Append(schemaTypeName2).Append(" ").Append(valueMember2.Name).Append(" = ").Append(valueMember2.FieldNumber);
+ bool flag10 = valueMember2.DefaultValue != null;
+ if (flag10)
+ {
+ bool flag11 = valueMember2.DefaultValue is string;
+ if (flag11)
+ {
+ builder.Append(" [default = \"").Append(valueMember2.DefaultValue).Append("\"]");
+ }
+ else
+ {
+ bool flag12 = valueMember2.DefaultValue is bool;
+ if (flag12)
+ {
+ builder.Append(((bool)valueMember2.DefaultValue) ? " [default = true]" : " [default = false]");
+ }
+ else
+ {
+ builder.Append(" [default = ").Append(valueMember2.DefaultValue).Append(']');
+ }
+ }
+ }
+ bool flag13 = valueMember2.ItemType != null && valueMember2.IsPacked;
+ if (flag13)
+ {
+ builder.Append(" [packed=true]");
+ }
+ builder.Append(';');
+ bool flag14 = schemaTypeName2 == "bcl.NetObjectProxy" && valueMember2.AsReference && !valueMember2.DynamicType;
+ if (flag14)
+ {
+ builder.Append(" // reference-tracked ").Append(valueMember2.GetSchemaTypeName(false, ref requiresBclImport));
+ }
+ }
+ bool flag15 = this.subTypes != null && this.subTypes.Count != 0;
+ if (flag15)
+ {
+ MetaType.NewLine(builder, indent + 1).Append("// the following represent sub-types; at most 1 should have a value");
+ SubType[] array6 = new SubType[this.subTypes.Count];
+ this.subTypes.CopyTo(array6, 0);
+ Array.Sort<SubType>(array6, SubType.Comparer.Default);
+ foreach (SubType subType in array6)
+ {
+ string schemaTypeName3 = subType.DerivedType.GetSchemaTypeName();
+ MetaType.NewLine(builder, indent + 1).Append("optional ").Append(schemaTypeName3).Append(" ").Append(schemaTypeName3).Append(" = ").Append(subType.FieldNumber).Append(';');
+ }
+ }
+ MetaType.NewLine(builder, indent).Append('}');
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/MetaType.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/MetaType.cs.meta new file mode 100644 index 00000000..4dcc0567 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/MetaType.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9896348409133c84db5b167634c43101 +timeCreated: 1611404191 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/MutableList.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/MutableList.cs new file mode 100644 index 00000000..3afa5609 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/MutableList.cs @@ -0,0 +1,29 @@ +using System;
+
+namespace ProtoBuf.Meta
+{
+ internal sealed class MutableList : BasicList
+ {
+ public new object this[int index]
+ {
+ get
+ {
+ return this.head[index];
+ }
+ set
+ {
+ this.head[index] = value;
+ }
+ }
+
+ public void RemoveLast()
+ {
+ this.head.RemoveLastWithMutate();
+ }
+
+ public new void Clear()
+ {
+ this.head.Clear();
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/MutableList.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/MutableList.cs.meta new file mode 100644 index 00000000..0ee40320 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/MutableList.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9075f746967b13049b559b21f9ba847f +timeCreated: 1611404139 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/RuntimeTypeModel.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/RuntimeTypeModel.cs new file mode 100644 index 00000000..2975c163 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/RuntimeTypeModel.cs @@ -0,0 +1,1160 @@ +using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Text;
+using System.Threading;
+using ProtoBuf.Serializers;
+
+namespace ProtoBuf.Meta
+{
+ public sealed class RuntimeTypeModel : TypeModel
+ {
+ public bool InferTagFromNameDefault
+ {
+ get
+ {
+ return this.GetOption(1);
+ }
+ set
+ {
+ this.SetOption(1, value);
+ }
+ }
+
+ public bool AutoAddProtoContractTypesOnly
+ {
+ get
+ {
+ return this.GetOption(128);
+ }
+ set
+ {
+ this.SetOption(128, value);
+ }
+ }
+
+ public bool UseImplicitZeroDefaults
+ {
+ get
+ {
+ return this.GetOption(32);
+ }
+ set
+ {
+ bool flag = !value && this.GetOption(2);
+ if (flag)
+ {
+ throw new InvalidOperationException("UseImplicitZeroDefaults cannot be disabled on the default model");
+ }
+ this.SetOption(32, value);
+ }
+ }
+
+ public bool AllowParseableTypes
+ {
+ get
+ {
+ return this.GetOption(64);
+ }
+ set
+ {
+ this.SetOption(64, value);
+ }
+ }
+
+ public static RuntimeTypeModel Default
+ {
+ get
+ {
+ return RuntimeTypeModel.Singleton.Value;
+ }
+ }
+
+ public static RuntimeTypeModel ThreadDefault
+ {
+ get
+ {
+ return RuntimeTypeModel.Singleton.DefaultValue;
+ }
+ }
+
+ public MetaType this[Type type]
+ {
+ get
+ {
+ return (MetaType)this.types[this.FindOrAddAuto(type, true, false, false)];
+ }
+ }
+
+ public bool AutoAddMissingTypes
+ {
+ get
+ {
+ return this.GetOption(8);
+ }
+ set
+ {
+ bool flag = !value && this.GetOption(2);
+ if (flag)
+ {
+ throw new InvalidOperationException("The default model must allow missing types");
+ }
+ this.ThrowIfFrozen();
+ this.SetOption(8, value);
+ }
+ }
+
+ public int MetadataTimeoutMilliseconds
+ {
+ get
+ {
+ return this.metadataTimeoutMilliseconds;
+ }
+ set
+ {
+ bool flag = value <= 0;
+ if (flag)
+ {
+ throw new ArgumentOutOfRangeException("MetadataTimeoutMilliseconds");
+ }
+ this.metadataTimeoutMilliseconds = value;
+ }
+ }
+
+ public int LockCount
+ {
+ get
+ {
+ return this.lockCount;
+ }
+ }
+
+ public event LockContentedEventHandler LockContended;
+
+ private byte options;
+
+ private const byte OPTIONS_InferTagFromNameDefault = 1;
+
+ private const byte OPTIONS_IsDefaultModel = 2;
+
+ private const byte OPTIONS_Frozen = 4;
+
+ private const byte OPTIONS_AutoAddMissingTypes = 8;
+
+ private const byte OPTIONS_UseImplicitZeroDefaults = 32;
+
+ private const byte OPTIONS_AllowParseableTypes = 64;
+
+ private const byte OPTIONS_AutoAddProtoContractTypesOnly = 128;
+
+ private static readonly BasicList.MatchPredicate MetaTypeFinder = new BasicList.MatchPredicate(RuntimeTypeModel.MetaTypeFinderImpl);
+
+ private static readonly BasicList.MatchPredicate BasicTypeFinder = new BasicList.MatchPredicate(RuntimeTypeModel.BasicTypeFinderImpl);
+
+ private BasicList basicTypes = new BasicList();
+
+ private readonly BasicList types = new BasicList();
+
+ private int metadataTimeoutMilliseconds = 5000;
+
+ private int lockCount;
+
+ private int contentionCounter = 1;
+
+ private MethodInfo defaultFactory;
+
+ private sealed class Singleton
+ {
+ internal static readonly RuntimeTypeModel Value = new RuntimeTypeModel(true);
+
+ private static RuntimeTypeModel ThreadValue = null;
+
+ internal static RuntimeTypeModel DefaultValue = null;
+
+ private Singleton()
+ {
+ }
+
+ public static void SetMultiThread(bool multiThread)
+ {
+ if (multiThread)
+ {
+ RuntimeTypeModel.Singleton.ThreadValue = new RuntimeTypeModel(true);
+ RuntimeTypeModel.Singleton.DefaultValue = RuntimeTypeModel.Singleton.ThreadValue;
+ }
+ else
+ {
+ RuntimeTypeModel.Singleton.DefaultValue = RuntimeTypeModel.Singleton.Value;
+ }
+ }
+ }
+
+ private sealed class BasicType
+ {
+ public Type Type
+ {
+ get
+ {
+ return this.type;
+ }
+ }
+
+ public IProtoSerializer Serializer
+ {
+ get
+ {
+ return this.serializer;
+ }
+ }
+
+ private readonly Type type;
+
+ private readonly IProtoSerializer serializer;
+
+ public BasicType(Type type, IProtoSerializer serializer)
+ {
+ this.type = type;
+ this.serializer = serializer;
+ }
+ }
+
+ private bool GetOption(byte option)
+ {
+ return (this.options & option) == option;
+ }
+
+ private void SetOption(byte option, bool value)
+ {
+ if (value)
+ {
+ this.options |= option;
+ }
+ else
+ {
+ this.options &=(byte) ~option;
+ }
+ }
+
+ public static void SetMultiThread(bool multiThread)
+ {
+ RuntimeTypeModel.Singleton.SetMultiThread(multiThread);
+ }
+
+ public IEnumerable GetTypes()
+ {
+ return this.types;
+ }
+
+ public override string GetSchema(Type type)
+ {
+ BasicList basicList = new BasicList();
+ MetaType metaType = null;
+ bool flag = false;
+ bool flag2 = type == null;
+ if (flag2)
+ {
+ foreach (object obj in this.types)
+ {
+ MetaType metaType2 = (MetaType)obj;
+ MetaType surrogateOrBaseOrSelf = metaType2.GetSurrogateOrBaseOrSelf(false);
+ bool flag3 = !basicList.Contains(surrogateOrBaseOrSelf);
+ if (flag3)
+ {
+ basicList.Add(surrogateOrBaseOrSelf);
+ this.CascadeDependents(basicList, surrogateOrBaseOrSelf);
+ }
+ }
+ }
+ else
+ {
+ Type underlyingType = Helpers.GetUnderlyingType(type);
+ bool flag4 = underlyingType != null;
+ if (flag4)
+ {
+ type = underlyingType;
+ }
+ WireType wireType;
+ flag = (ValueMember.TryGetCoreSerializer(this, DataFormat.Default, type, out wireType, false, false, false, false) != null);
+ bool flag5 = !flag;
+ if (flag5)
+ {
+ int num = this.FindOrAddAuto(type, false, false, false);
+ bool flag6 = num < 0;
+ if (flag6)
+ {
+ throw new ArgumentException("The type specified is not a contract-type", "type");
+ }
+ metaType = ((MetaType)this.types[num]).GetSurrogateOrBaseOrSelf(false);
+ basicList.Add(metaType);
+ this.CascadeDependents(basicList, metaType);
+ }
+ }
+ StringBuilder stringBuilder = new StringBuilder();
+ string text = null;
+ bool flag7 = !flag;
+ if (flag7)
+ {
+ IEnumerable enumerable = (metaType == null) ? this.types : basicList;
+ foreach (object obj2 in enumerable)
+ {
+ MetaType metaType3 = (MetaType)obj2;
+ bool isList = metaType3.IsList;
+ if (!isList)
+ {
+ string @namespace = metaType3.Type.Namespace;
+ bool flag8 = !Helpers.IsNullOrEmpty(@namespace);
+ if (flag8)
+ {
+ bool flag9 = @namespace.StartsWith("System.");
+ if (!flag9)
+ {
+ bool flag10 = text == null;
+ if (flag10)
+ {
+ text = @namespace;
+ }
+ else
+ {
+ bool flag11 = text == @namespace;
+ if (!flag11)
+ {
+ text = null;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ bool flag12 = !Helpers.IsNullOrEmpty(text);
+ if (flag12)
+ {
+ stringBuilder.Append("package ").Append(text).Append(';');
+ Helpers.AppendLine(stringBuilder);
+ }
+ bool flag13 = false;
+ StringBuilder stringBuilder2 = new StringBuilder();
+ MetaType[] array = new MetaType[basicList.Count];
+ basicList.CopyTo(array, 0);
+ Array.Sort<MetaType>(array, MetaType.Comparer.Default);
+ bool flag14 = flag;
+ if (flag14)
+ {
+ Helpers.AppendLine(stringBuilder2).Append("message ").Append(type.Name).Append(" {");
+ MetaType.NewLine(stringBuilder2, 1).Append("optional ").Append(this.GetSchemaTypeName(type, DataFormat.Default, false, false, ref flag13)).Append(" value = 1;");
+ Helpers.AppendLine(stringBuilder2).Append('}');
+ }
+ else
+ {
+ foreach (MetaType metaType4 in array)
+ {
+ bool flag15 = metaType4.IsList && metaType4 != metaType;
+ if (!flag15)
+ {
+ metaType4.WriteSchema(stringBuilder2, 0, ref flag13);
+ }
+ }
+ }
+ bool flag16 = flag13;
+ if (flag16)
+ {
+ stringBuilder.Append("import \"bcl.proto\"; // schema for protobuf-net's handling of core .NET types");
+ Helpers.AppendLine(stringBuilder);
+ }
+ return Helpers.AppendLine(stringBuilder.Append(stringBuilder2)).ToString();
+ }
+
+ private void CascadeDependents(BasicList list, MetaType metaType)
+ {
+ bool isList = metaType.IsList;
+ if (isList)
+ {
+ Type listItemType = TypeModel.GetListItemType(this, metaType.Type);
+ WireType wireType;
+ IProtoSerializer protoSerializer = ValueMember.TryGetCoreSerializer(this, DataFormat.Default, listItemType, out wireType, false, false, false, false);
+ bool flag = protoSerializer == null;
+ if (flag)
+ {
+ int num = this.FindOrAddAuto(listItemType, false, false, false);
+ bool flag2 = num >= 0;
+ if (flag2)
+ {
+ MetaType metaType2 = ((MetaType)this.types[num]).GetSurrogateOrBaseOrSelf(false);
+ bool flag3 = !list.Contains(metaType2);
+ if (flag3)
+ {
+ list.Add(metaType2);
+ this.CascadeDependents(list, metaType2);
+ }
+ }
+ }
+ }
+ else
+ {
+ bool isAutoTuple = metaType.IsAutoTuple;
+ MetaType metaType2;
+ if (isAutoTuple)
+ {
+ MemberInfo[] array;
+ bool flag4 = MetaType.ResolveTupleConstructor(metaType.Type, out array) != null;
+ if (flag4)
+ {
+ for (int i = 0; i < array.Length; i++)
+ {
+ Type type = null;
+ bool flag5 = array[i] is PropertyInfo;
+ if (flag5)
+ {
+ type = ((PropertyInfo)array[i]).PropertyType;
+ }
+ else
+ {
+ bool flag6 = array[i] is FieldInfo;
+ if (flag6)
+ {
+ type = ((FieldInfo)array[i]).FieldType;
+ }
+ }
+ WireType wireType2;
+ IProtoSerializer protoSerializer2 = ValueMember.TryGetCoreSerializer(this, DataFormat.Default, type, out wireType2, false, false, false, false);
+ bool flag7 = protoSerializer2 == null;
+ if (flag7)
+ {
+ int num2 = this.FindOrAddAuto(type, false, false, false);
+ bool flag8 = num2 >= 0;
+ if (flag8)
+ {
+ metaType2 = ((MetaType)this.types[num2]).GetSurrogateOrBaseOrSelf(false);
+ bool flag9 = !list.Contains(metaType2);
+ if (flag9)
+ {
+ list.Add(metaType2);
+ this.CascadeDependents(list, metaType2);
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ foreach (object obj in metaType.Fields)
+ {
+ ValueMember valueMember = (ValueMember)obj;
+ Type type2 = valueMember.ItemType;
+ bool flag10 = type2 == null;
+ if (flag10)
+ {
+ type2 = valueMember.MemberType;
+ }
+ WireType wireType3;
+ IProtoSerializer protoSerializer3 = ValueMember.TryGetCoreSerializer(this, DataFormat.Default, type2, out wireType3, false, false, false, false);
+ bool flag11 = protoSerializer3 == null;
+ if (flag11)
+ {
+ int num3 = this.FindOrAddAuto(type2, false, false, false);
+ bool flag12 = num3 >= 0;
+ if (flag12)
+ {
+ metaType2 = ((MetaType)this.types[num3]).GetSurrogateOrBaseOrSelf(false);
+ bool flag13 = !list.Contains(metaType2);
+ if (flag13)
+ {
+ list.Add(metaType2);
+ this.CascadeDependents(list, metaType2);
+ }
+ }
+ }
+ }
+ }
+ bool hasSubtypes = metaType.HasSubtypes;
+ if (hasSubtypes)
+ {
+ foreach (SubType subType in metaType.GetSubtypes())
+ {
+ metaType2 = subType.DerivedType.GetSurrogateOrSelf();
+ bool flag14 = !list.Contains(metaType2);
+ if (flag14)
+ {
+ list.Add(metaType2);
+ this.CascadeDependents(list, metaType2);
+ }
+ }
+ }
+ metaType2 = metaType.BaseType;
+ bool flag15 = metaType2 != null;
+ if (flag15)
+ {
+ metaType2 = metaType2.GetSurrogateOrSelf();
+ }
+ bool flag16 = metaType2 != null && !list.Contains(metaType2);
+ if (flag16)
+ {
+ list.Add(metaType2);
+ this.CascadeDependents(list, metaType2);
+ }
+ }
+ }
+
+ internal RuntimeTypeModel(bool isDefault)
+ {
+ this.AutoAddMissingTypes = true;
+ this.UseImplicitZeroDefaults = true;
+ this.SetOption(2, isDefault);
+ }
+
+ internal MetaType FindWithoutAdd(Type type)
+ {
+ foreach (object obj in this.types)
+ {
+ MetaType metaType = (MetaType)obj;
+ bool flag = metaType.Type == type;
+ if (flag)
+ {
+ bool pending = metaType.Pending;
+ if (pending)
+ {
+ this.WaitOnLock(metaType);
+ }
+ return metaType;
+ }
+ }
+ Type type2 = TypeModel.ResolveProxies(type);
+ return (type2 == null) ? null : this.FindWithoutAdd(type2);
+ }
+
+ private static bool MetaTypeFinderImpl(object value, object ctx)
+ {
+ return ((MetaType)value).Type == (Type)ctx;
+ }
+
+ private static bool BasicTypeFinderImpl(object value, object ctx)
+ {
+ return ((RuntimeTypeModel.BasicType)value).Type == (Type)ctx;
+ }
+
+ private void WaitOnLock(MetaType type)
+ {
+ int opaqueToken = 0;
+ try
+ {
+ this.TakeLock(ref opaqueToken);
+ }
+ finally
+ {
+ this.ReleaseLock(opaqueToken);
+ }
+ }
+
+ internal IProtoSerializer TryGetBasicTypeSerializer(Type type)
+ {
+ int num = this.basicTypes.IndexOf(RuntimeTypeModel.BasicTypeFinder, type);
+ bool flag = num >= 0;
+ IProtoSerializer result;
+ if (flag)
+ {
+ result = ((RuntimeTypeModel.BasicType)this.basicTypes[num]).Serializer;
+ }
+ else
+ {
+ BasicList obj = this.basicTypes;
+ lock (obj)
+ {
+ num = this.basicTypes.IndexOf(RuntimeTypeModel.BasicTypeFinder, type);
+ bool flag2 = num >= 0;
+ if (flag2)
+ {
+ result = ((RuntimeTypeModel.BasicType)this.basicTypes[num]).Serializer;
+ }
+ else
+ {
+ MetaType.AttributeFamily contractFamily = MetaType.GetContractFamily(this, type, null);
+ WireType wireType;
+ IProtoSerializer protoSerializer = (contractFamily == MetaType.AttributeFamily.None) ? ValueMember.TryGetCoreSerializer(this, DataFormat.Default, type, out wireType, false, false, false, false) : null;
+ bool flag3 = protoSerializer != null;
+ if (flag3)
+ {
+ this.basicTypes.Add(new RuntimeTypeModel.BasicType(type, protoSerializer));
+ }
+ result = protoSerializer;
+ }
+ }
+ }
+ return result;
+ }
+
+ public void Clear()
+ {
+ this.types.Clear();
+ }
+
+ internal int FindOrAddAuto(Type type, bool demand, bool addWithContractOnly, bool addEvenIfAutoDisabled)
+ {
+ int num = this.types.IndexOf(RuntimeTypeModel.MetaTypeFinder, type);
+ bool flag = num >= 0;
+ int result;
+ if (flag)
+ {
+ MetaType metaType = (MetaType)this.types[num];
+ bool pending = metaType.Pending;
+ if (pending)
+ {
+ this.WaitOnLock(metaType);
+ }
+ result = num;
+ }
+ else
+ {
+ bool flag2 = this.AutoAddMissingTypes || addEvenIfAutoDisabled;
+ bool flag3 = !Helpers.IsEnum(type) && this.TryGetBasicTypeSerializer(type) != null;
+ if (flag3)
+ {
+ bool flag4 = flag2 && !addWithContractOnly;
+ if (flag4)
+ {
+ throw MetaType.InbuiltType(type);
+ }
+ result = -1;
+ }
+ else
+ {
+ Type type2 = TypeModel.ResolveProxies(type);
+ bool flag5 = type2 != null;
+ if (flag5)
+ {
+ num = this.types.IndexOf(RuntimeTypeModel.MetaTypeFinder, type2);
+ type = type2;
+ }
+ bool flag6 = num < 0;
+ if (flag6)
+ {
+ int opaqueToken = 0;
+ try
+ {
+ this.TakeLock(ref opaqueToken);
+ MetaType metaType;
+ bool flag7 = (metaType = this.RecogniseCommonTypes(type)) == null;
+ if (flag7)
+ {
+ MetaType.AttributeFamily contractFamily = MetaType.GetContractFamily(this, type, null);
+ bool flag8 = contractFamily == MetaType.AttributeFamily.AutoTuple;
+ if (flag8)
+ {
+ addEvenIfAutoDisabled = (flag2 = true);
+ }
+ bool flag9 = !flag2 || (!Helpers.IsEnum(type) && addWithContractOnly && contractFamily == MetaType.AttributeFamily.None);
+ if (flag9)
+ {
+ if (demand)
+ {
+ TypeModel.ThrowUnexpectedType(type);
+ }
+ return num;
+ }
+ metaType = this.Create(type);
+ }
+ metaType.Pending = true;
+ bool flag10 = false;
+ int num2 = this.types.IndexOf(RuntimeTypeModel.MetaTypeFinder, type);
+ bool flag11 = num2 < 0;
+ if (flag11)
+ {
+ this.ThrowIfFrozen();
+ num = this.types.Add(metaType);
+ flag10 = true;
+ }
+ else
+ {
+ num = num2;
+ }
+ bool flag12 = flag10;
+ if (flag12)
+ {
+ metaType.ApplyDefaultBehaviour();
+ metaType.Pending = false;
+ }
+ }
+ finally
+ {
+ this.ReleaseLock(opaqueToken);
+ }
+ }
+ result = num;
+ }
+ }
+ return result;
+ }
+
+ private MetaType RecogniseCommonTypes(Type type)
+ {
+ return null;
+ }
+
+ private MetaType Create(Type type)
+ {
+ this.ThrowIfFrozen();
+ return new MetaType(this, type, this.defaultFactory);
+ }
+
+ public MetaType Add(Type type, bool applyDefaultBehaviour)
+ {
+ bool flag = type == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("type");
+ }
+ MetaType metaType = this.FindWithoutAdd(type);
+ bool flag2 = metaType != null;
+ MetaType result;
+ if (flag2)
+ {
+ result = metaType;
+ }
+ else
+ {
+ int opaqueToken = 0;
+ bool flag3 = type.IsInterface && base.MapType(MetaType.ienumerable).IsAssignableFrom(type) && TypeModel.GetListItemType(this, type) == null;
+ if (flag3)
+ {
+ throw new ArgumentException("IEnumerable[<T>] data cannot be used as a meta-type unless an Add method can be resolved");
+ }
+ try
+ {
+ metaType = this.RecogniseCommonTypes(type);
+ bool flag4 = metaType != null;
+ if (flag4)
+ {
+ bool flag5 = !applyDefaultBehaviour;
+ if (flag5)
+ {
+ throw new ArgumentException("Default behaviour must be observed for certain types with special handling; " + type.FullName, "applyDefaultBehaviour");
+ }
+ applyDefaultBehaviour = false;
+ }
+ bool flag6 = metaType == null;
+ if (flag6)
+ {
+ metaType = this.Create(type);
+ }
+ metaType.Pending = true;
+ this.TakeLock(ref opaqueToken);
+ bool flag7 = this.FindWithoutAdd(type) != null;
+ if (flag7)
+ {
+ throw new ArgumentException("Duplicate type", "type");
+ }
+ this.ThrowIfFrozen();
+ this.types.Add(metaType);
+ bool flag8 = applyDefaultBehaviour;
+ if (flag8)
+ {
+ metaType.ApplyDefaultBehaviour();
+ }
+ metaType.Pending = false;
+ }
+ finally
+ {
+ this.ReleaseLock(opaqueToken);
+ }
+ result = metaType;
+ }
+ return result;
+ }
+
+ private void ThrowIfFrozen()
+ {
+ bool option = this.GetOption(4);
+ if (option)
+ {
+ throw new InvalidOperationException("The model cannot be changed once frozen");
+ }
+ }
+
+ public void Freeze()
+ {
+ bool option = this.GetOption(2);
+ if (option)
+ {
+ throw new InvalidOperationException("The default model cannot be frozen");
+ }
+ this.SetOption(4, true);
+ }
+
+ protected override int GetKeyImpl(Type type)
+ {
+ return this.GetKey(type, false, true);
+ }
+
+ internal int GetKey(Type type, bool demand, bool getBaseKey)
+ {
+ Helpers.DebugAssert(type != null);
+ int result;
+ try
+ {
+ int num = this.FindOrAddAuto(type, demand, true, false);
+ bool flag = num >= 0;
+ if (flag)
+ {
+ MetaType metaType = (MetaType)this.types[num];
+ if (getBaseKey)
+ {
+ metaType = MetaType.GetRootType(metaType);
+ num = this.FindOrAddAuto(metaType.Type, true, true, false);
+ }
+ }
+ result = num;
+ }
+ catch (NotSupportedException)
+ {
+ throw;
+ }
+ catch (Exception ex)
+ {
+ bool flag2 = ex.Message.IndexOf(type.FullName) >= 0;
+ if (flag2)
+ {
+ throw;
+ }
+ throw new ProtoException(ex.Message + " (" + type.FullName + ")", ex);
+ }
+ return result;
+ }
+
+ protected internal override void Serialize(int key, object value, ProtoWriter dest)
+ {
+ ((MetaType)this.types[key]).Serializer.Write(value, dest);
+ }
+
+ protected internal override object Deserialize(int key, object value, ProtoReader source)
+ {
+ IProtoSerializer serializer = ((MetaType)this.types[key]).Serializer;
+ bool flag = value == null && Helpers.IsValueType(serializer.ExpectedType);
+ object result;
+ if (flag)
+ {
+ bool requiresOldValue = serializer.RequiresOldValue;
+ if (requiresOldValue)
+ {
+ value = Activator.CreateInstance(serializer.ExpectedType);
+ }
+ result = serializer.Read(value, source);
+ }
+ else
+ {
+ result = serializer.Read(value, source);
+ }
+ return result;
+ }
+
+ internal bool IsPrepared(Type type)
+ {
+ MetaType metaType = this.FindWithoutAdd(type);
+ return metaType != null && metaType.IsPrepared();
+ }
+
+ internal EnumSerializer.EnumPair[] GetEnumMap(Type type)
+ {
+ int num = this.FindOrAddAuto(type, false, false, false);
+ return (num < 0) ? null : ((MetaType)this.types[num]).GetEnumMap();
+ }
+
+ internal void TakeLock(ref int opaqueToken)
+ {
+ opaqueToken = 0;
+ bool flag = Monitor.TryEnter(this.types, this.metadataTimeoutMilliseconds);
+ if (flag)
+ {
+ opaqueToken = this.GetContention();
+ this.lockCount++;
+ return;
+ }
+ this.AddContention();
+ throw new TimeoutException("Timeout while inspecting metadata; this may indicate a deadlock. This can often be avoided by preparing necessary serializers during application initialization, rather than allowing multiple threads to perform the initial metadata inspection; please also see the LockContended event");
+ }
+
+ private int GetContention()
+ {
+ return Interlocked.CompareExchange(ref this.contentionCounter, 0, 0);
+ }
+
+ private void AddContention()
+ {
+ Interlocked.Increment(ref this.contentionCounter);
+ }
+
+ internal void ReleaseLock(int opaqueToken)
+ {
+ bool flag = opaqueToken != 0;
+ if (flag)
+ {
+ Monitor.Exit(this.types);
+ bool flag2 = opaqueToken != this.GetContention();
+ if (flag2)
+ {
+ LockContentedEventHandler lockContended = this.LockContended;
+ bool flag3 = lockContended != null;
+ if (flag3)
+ {
+ string stackTrace;
+ try
+ {
+ throw new ProtoException();
+ }
+ catch (Exception ex)
+ {
+ stackTrace = ex.StackTrace;
+ }
+ lockContended(this, new LockContentedEventArgs(stackTrace));
+ }
+ }
+ }
+ }
+
+ internal void ResolveListTypes(Type type, ref Type itemType, ref Type defaultType)
+ {
+ bool flag = type == null;
+ if (!flag)
+ {
+ bool flag2 = Helpers.GetTypeCode(type) != ProtoTypeCode.Unknown;
+ if (!flag2)
+ {
+ bool ignoreListHandling = this[type].IgnoreListHandling;
+ if (!ignoreListHandling)
+ {
+ bool isArray = type.IsArray;
+ if (isArray)
+ {
+ bool flag3 = type.GetArrayRank() != 1;
+ if (flag3)
+ {
+ throw new NotSupportedException("Multi-dimension arrays are supported");
+ }
+ itemType = type.GetElementType();
+ bool flag4 = itemType == base.MapType(typeof(byte));
+ if (flag4)
+ {
+ Type type2;
+ itemType = (type2 = null);
+ defaultType = type2;
+ }
+ else
+ {
+ defaultType = type;
+ }
+ }
+ bool flag5 = itemType == null;
+ if (flag5)
+ {
+ itemType = TypeModel.GetListItemType(this, type);
+ }
+ bool flag6 = itemType != null;
+ if (flag6)
+ {
+ Type type3 = null;
+ Type type4 = null;
+ this.ResolveListTypes(itemType, ref type3, ref type4);
+ bool flag7 = type3 != null;
+ if (flag7)
+ {
+ throw TypeModel.CreateNestedListsNotSupported();
+ }
+ }
+ bool flag8 = itemType != null && defaultType == null;
+ if (flag8)
+ {
+ bool flag9 = type.IsClass && !type.IsAbstract && Helpers.GetConstructor(type, Helpers.EmptyTypes, true) != null;
+ if (flag9)
+ {
+ defaultType = type;
+ }
+ bool flag10 = defaultType == null;
+ if (flag10)
+ {
+ bool isInterface = type.IsInterface;
+ if (isInterface)
+ {
+ Type[] genericArguments = null;
+ bool flag11 = type.IsGenericType && type.GetGenericTypeDefinition() == base.MapType(typeof(IDictionary<, >)) && itemType == base.MapType(typeof(KeyValuePair<, >)).MakeGenericType(genericArguments = type.GetGenericArguments());
+ if (flag11)
+ {
+ defaultType = base.MapType(typeof(Dictionary<, >)).MakeGenericType(genericArguments);
+ }
+ else
+ {
+ defaultType = base.MapType(typeof(List<>)).MakeGenericType(new Type[]
+ {
+ itemType
+ });
+ }
+ }
+ }
+ bool flag12 = defaultType != null && !Helpers.IsAssignableFrom(type, defaultType);
+ if (flag12)
+ {
+ defaultType = null;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ internal string GetSchemaTypeName(Type effectiveType, DataFormat dataFormat, bool asReference, bool dynamicType, ref bool requiresBclImport)
+ {
+ Type underlyingType = Helpers.GetUnderlyingType(effectiveType);
+ bool flag = underlyingType != null;
+ if (flag)
+ {
+ effectiveType = underlyingType;
+ }
+ bool flag2 = effectiveType == base.MapType(typeof(byte[]));
+ string result;
+ if (flag2)
+ {
+ result = "bytes";
+ }
+ else
+ {
+ WireType wireType;
+ IProtoSerializer protoSerializer = ValueMember.TryGetCoreSerializer(this, dataFormat, effectiveType, out wireType, false, false, false, false);
+ bool flag3 = protoSerializer == null;
+ if (flag3)
+ {
+ bool flag4 = asReference || dynamicType;
+ if (flag4)
+ {
+ requiresBclImport = true;
+ result = "bcl.NetObjectProxy";
+ }
+ else
+ {
+ result = this[effectiveType].GetSurrogateOrBaseOrSelf(true).GetSchemaTypeName();
+ }
+ }
+ else
+ {
+ bool flag5 = protoSerializer is ParseableSerializer;
+ if (!flag5)
+ {
+ ProtoTypeCode typeCode = Helpers.GetTypeCode(effectiveType);
+ switch (typeCode)
+ {
+ case ProtoTypeCode.Boolean:
+ return "bool";
+ case ProtoTypeCode.Char:
+ case ProtoTypeCode.Byte:
+ case ProtoTypeCode.UInt16:
+ case ProtoTypeCode.UInt32:
+ if (dataFormat != DataFormat.FixedSize)
+ {
+ return "uint32";
+ }
+ return "fixed32";
+ case ProtoTypeCode.SByte:
+ case ProtoTypeCode.Int16:
+ case ProtoTypeCode.Int32:
+ if (dataFormat == DataFormat.ZigZag)
+ {
+ return "sint32";
+ }
+ if (dataFormat != DataFormat.FixedSize)
+ {
+ return "int32";
+ }
+ return "sfixed32";
+ case ProtoTypeCode.Int64:
+ if (dataFormat == DataFormat.ZigZag)
+ {
+ return "sint64";
+ }
+ if (dataFormat != DataFormat.FixedSize)
+ {
+ return "int64";
+ }
+ return "sfixed64";
+ case ProtoTypeCode.UInt64:
+ if (dataFormat != DataFormat.FixedSize)
+ {
+ return "uint64";
+ }
+ return "fixed64";
+ case ProtoTypeCode.Single:
+ return "float";
+ case ProtoTypeCode.Double:
+ return "double";
+ case ProtoTypeCode.Decimal:
+ requiresBclImport = true;
+ return "bcl.Decimal";
+ case ProtoTypeCode.DateTime:
+ requiresBclImport = true;
+ return "bcl.DateTime";
+ case (ProtoTypeCode)17:
+ break;
+ case ProtoTypeCode.String:
+ if (asReference)
+ {
+ requiresBclImport = true;
+ }
+ return asReference ? "bcl.NetObjectProxy" : "string";
+ default:
+ if (typeCode == ProtoTypeCode.TimeSpan)
+ {
+ requiresBclImport = true;
+ return "bcl.TimeSpan";
+ }
+ if (typeCode == ProtoTypeCode.Guid)
+ {
+ requiresBclImport = true;
+ return "bcl.Guid";
+ }
+ break;
+ }
+ throw new NotSupportedException("No .proto map found for: " + effectiveType.FullName);
+ }
+ if (asReference)
+ {
+ requiresBclImport = true;
+ }
+ result = (asReference ? "bcl.NetObjectProxy" : "string");
+ }
+ }
+ return result;
+ }
+
+ public void SetDefaultFactory(MethodInfo methodInfo)
+ {
+ this.VerifyFactory(methodInfo, null);
+ this.defaultFactory = methodInfo;
+ }
+
+ internal void VerifyFactory(MethodInfo factory, Type type)
+ {
+ bool flag = factory != null;
+ if (flag)
+ {
+ bool flag2 = type != null && Helpers.IsValueType(type);
+ if (flag2)
+ {
+ throw new InvalidOperationException();
+ }
+ bool flag3 = !factory.IsStatic;
+ if (flag3)
+ {
+ throw new ArgumentException("A factory-method must be static", "factory");
+ }
+ bool flag4 = type != null && factory.ReturnType != type && factory.ReturnType != base.MapType(typeof(object));
+ if (flag4)
+ {
+ throw new ArgumentException("The factory-method must return object" + ((type == null) ? "" : (" or " + type.FullName)), "factory");
+ }
+ bool flag5 = !CallbackSet.CheckCallbackParameters(this, factory);
+ if (flag5)
+ {
+ throw new ArgumentException("Invalid factory signature in " + factory.DeclaringType.FullName + "." + factory.Name, "factory");
+ }
+ }
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/RuntimeTypeModel.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/RuntimeTypeModel.cs.meta new file mode 100644 index 00000000..547e89c2 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/RuntimeTypeModel.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 05191c47ba04cdf4e9b086621a0fb424 +timeCreated: 1611402962 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/SubType.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/SubType.cs new file mode 100644 index 00000000..6686ab73 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/SubType.cs @@ -0,0 +1,117 @@ +using System;
+using System.Collections;
+using System.Collections.Generic;
+using ProtoBuf.Serializers;
+
+namespace ProtoBuf.Meta
+{
+ public sealed class SubType
+ {
+ public int FieldNumber
+ {
+ get
+ {
+ return this.fieldNumber;
+ }
+ }
+
+ public MetaType DerivedType
+ {
+ get
+ {
+ return this.derivedType;
+ }
+ }
+
+ internal IProtoSerializer Serializer
+ {
+ get
+ {
+ bool flag = this.serializer == null;
+ if (flag)
+ {
+ this.serializer = this.BuildSerializer();
+ }
+ return this.serializer;
+ }
+ }
+
+ private readonly int fieldNumber;
+
+ private readonly MetaType derivedType;
+
+ private readonly DataFormat dataFormat;
+
+ private IProtoSerializer serializer;
+
+ internal sealed class Comparer : IComparer, IComparer<SubType>
+ {
+ public static readonly SubType.Comparer Default = new SubType.Comparer();
+
+ public int Compare(object x, object y)
+ {
+ return this.Compare(x as SubType, y as SubType);
+ }
+
+ public int Compare(SubType x, SubType y)
+ {
+ bool flag = x == y;
+ int result;
+ if (flag)
+ {
+ result = 0;
+ }
+ else
+ {
+ bool flag2 = x == null;
+ if (flag2)
+ {
+ result = -1;
+ }
+ else
+ {
+ bool flag3 = y == null;
+ if (flag3)
+ {
+ result = 1;
+ }
+ else
+ {
+ result = x.FieldNumber.CompareTo(y.FieldNumber);
+ }
+ }
+ }
+ return result;
+ }
+ }
+
+ public SubType(int fieldNumber, MetaType derivedType, DataFormat format)
+ {
+ bool flag = derivedType == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("derivedType");
+ }
+ bool flag2 = fieldNumber <= 0;
+ if (flag2)
+ {
+ throw new ArgumentOutOfRangeException("fieldNumber");
+ }
+ this.fieldNumber = fieldNumber;
+ this.derivedType = derivedType;
+ this.dataFormat = format;
+ }
+
+ private IProtoSerializer BuildSerializer()
+ {
+ WireType wireType = WireType.String;
+ bool flag = this.dataFormat == DataFormat.Group;
+ if (flag)
+ {
+ wireType = WireType.StartGroup;
+ }
+ IProtoSerializer tail = new SubItemSerializer(this.derivedType.Type, this.derivedType.GetKey(false, false), this.derivedType, false);
+ return new TagDecorator(this.fieldNumber, wireType, false, tail);
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/SubType.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/SubType.cs.meta new file mode 100644 index 00000000..dd423340 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/SubType.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c96bdfea838c34b4c8d995ee6bd2940f +timeCreated: 1611404538 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/TypeFormatEventArgs.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/TypeFormatEventArgs.cs new file mode 100644 index 00000000..ec466502 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/TypeFormatEventArgs.cs @@ -0,0 +1,76 @@ +using System;
+
+namespace ProtoBuf.Meta
+{
+ public class TypeFormatEventArgs : EventArgs
+ {
+ public Type Type
+ {
+ get
+ {
+ return this.type;
+ }
+ set
+ {
+ bool flag = this.type != value;
+ if (flag)
+ {
+ bool flag2 = this.typeFixed;
+ if (flag2)
+ {
+ throw new InvalidOperationException("The type is fixed and cannot be changed");
+ }
+ this.type = value;
+ }
+ }
+ }
+
+ public string FormattedName
+ {
+ get
+ {
+ return this.formattedName;
+ }
+ set
+ {
+ bool flag = this.formattedName != value;
+ if (flag)
+ {
+ bool flag2 = !this.typeFixed;
+ if (flag2)
+ {
+ throw new InvalidOperationException("The formatted-name is fixed and cannot be changed");
+ }
+ this.formattedName = value;
+ }
+ }
+ }
+
+ private Type type;
+
+ private string formattedName;
+
+ private readonly bool typeFixed;
+
+ internal TypeFormatEventArgs(string formattedName)
+ {
+ bool flag = Helpers.IsNullOrEmpty(formattedName);
+ if (flag)
+ {
+ throw new ArgumentNullException("formattedName");
+ }
+ this.formattedName = formattedName;
+ }
+
+ internal TypeFormatEventArgs(Type type)
+ {
+ bool flag = type == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("type");
+ }
+ this.type = type;
+ this.typeFixed = true;
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/TypeFormatEventArgs.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/TypeFormatEventArgs.cs.meta new file mode 100644 index 00000000..3699b0eb --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/TypeFormatEventArgs.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 22ffb555f8ce6f64aaf7b82ffbe091a3 +timeCreated: 1611403425 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/TypeFormatEventHandler.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/TypeFormatEventHandler.cs new file mode 100644 index 00000000..54e34016 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/TypeFormatEventHandler.cs @@ -0,0 +1,6 @@ +using System;
+
+namespace ProtoBuf.Meta
+{
+ public delegate void TypeFormatEventHandler(object sender, TypeFormatEventArgs args);
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/TypeFormatEventHandler.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/TypeFormatEventHandler.cs.meta new file mode 100644 index 00000000..47deaaff --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/TypeFormatEventHandler.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0741ed768de0a8d429019e070d73a230 +timeCreated: 1611402967 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/TypeModel.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/TypeModel.cs new file mode 100644 index 00000000..018d47c0 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/TypeModel.cs @@ -0,0 +1,1511 @@ +using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using ProtoBuf.Serializers;
+
+namespace ProtoBuf.Meta
+{
+ public abstract class TypeModel
+ {
+ public bool ForwardsOnly
+ {
+ get
+ {
+ return this.forwardsOnly;
+ }
+ set
+ {
+ this.forwardsOnly = value;
+ }
+ }
+
+ public event TypeFormatEventHandler DynamicTypeFormatting;
+
+ private static readonly Type ilist = typeof(IList);
+
+ private bool forwardsOnly;
+
+ private sealed class DeserializeItemsIterator<T> : TypeModel.DeserializeItemsIterator, IEnumerator<T>, IEnumerator, IDisposable, IEnumerable<T>, IEnumerable
+ {
+ public new T Current
+ {
+ get
+ {
+ return (T)((object)base.Current);
+ }
+ }
+
+ IEnumerator<T> IEnumerable<T>.GetEnumerator()
+ {
+ return this;
+ }
+
+ void IDisposable.Dispose()
+ {
+ }
+
+ public DeserializeItemsIterator(TypeModel model, Stream source, PrefixStyle style, int expectedField, SerializationContext context) : base(model, source, model.MapType(typeof(T)), style, expectedField, null, context)
+ {
+ }
+ }
+
+ private class DeserializeItemsIterator : IEnumerator, IEnumerable
+ {
+ public object Current
+ {
+ get
+ {
+ return this.current;
+ }
+ }
+
+ private bool haveObject;
+
+ private object current;
+
+ private readonly Stream source;
+
+ private readonly Type type;
+
+ private readonly PrefixStyle style;
+
+ private readonly int expectedField;
+
+ private readonly Serializer.TypeResolver resolver;
+
+ private readonly TypeModel model;
+
+ private readonly SerializationContext context;
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return this;
+ }
+
+ public bool MoveNext()
+ {
+ bool flag = this.haveObject;
+ if (flag)
+ {
+ int num;
+ this.current = this.model.DeserializeWithLengthPrefix(this.source, null, this.type, this.style, this.expectedField, this.resolver, out num, out this.haveObject, this.context);
+ }
+ return this.haveObject;
+ }
+
+ void IEnumerator.Reset()
+ {
+ throw new NotSupportedException();
+ }
+
+ public DeserializeItemsIterator(TypeModel model, Stream source, Type type, PrefixStyle style, int expectedField, Serializer.TypeResolver resolver, SerializationContext context)
+ {
+ this.haveObject = true;
+ this.source = source;
+ this.type = type;
+ this.style = style;
+ this.expectedField = expectedField;
+ this.resolver = resolver;
+ this.model = model;
+ this.context = context;
+ }
+ }
+
+ protected internal enum CallbackType
+ {
+ BeforeSerialize,
+ AfterSerialize,
+ BeforeDeserialize,
+ AfterDeserialize
+ }
+
+ protected internal Type MapType(Type type)
+ {
+ return this.MapType(type, true);
+ }
+
+ protected internal virtual Type MapType(Type type, bool demand)
+ {
+ return type;
+ }
+
+ private WireType GetWireType(ProtoTypeCode code, DataFormat format, ref Type type, out int modelKey)
+ {
+ modelKey = -1;
+ bool flag = Helpers.IsEnum(type);
+ WireType result = WireType.None;//!
+ if (flag)
+ {
+ modelKey = this.GetKey(ref type);
+ result = WireType.Variant;
+ }
+ else
+ {
+ switch (code)
+ {
+ case ProtoTypeCode.Boolean:
+ case ProtoTypeCode.Char:
+ case ProtoTypeCode.SByte:
+ case ProtoTypeCode.Byte:
+ case ProtoTypeCode.Int16:
+ case ProtoTypeCode.UInt16:
+ case ProtoTypeCode.Int32:
+ case ProtoTypeCode.UInt32:
+ return (format == DataFormat.FixedSize) ? WireType.Fixed32 : WireType.Variant;
+ case ProtoTypeCode.Int64:
+ case ProtoTypeCode.UInt64:
+ return (format == DataFormat.FixedSize) ? WireType.Fixed64 : WireType.Variant;
+ case ProtoTypeCode.Single:
+ return WireType.Fixed32;
+ case ProtoTypeCode.Double:
+ return WireType.Fixed64;
+ case ProtoTypeCode.Decimal:
+ case ProtoTypeCode.DateTime:
+ case ProtoTypeCode.String:
+ break;
+ case (ProtoTypeCode)17:
+ goto IL_99;
+ default:
+ if (code - ProtoTypeCode.TimeSpan > 3)
+ {
+ goto IL_99;
+ }
+ break;
+ }
+ return WireType.String;
+ IL_99:
+ bool flag2 = (modelKey = this.GetKey(ref type)) >= 0;
+ if (flag2)
+ {
+ result = WireType.String;
+ }
+ else
+ {
+ result = WireType.None;
+ }
+ }
+ return result;
+ }
+
+ internal bool TrySerializeAuxiliaryType(ProtoWriter writer, Type type, DataFormat format, int tag, object value, bool isInsideList)
+ {
+ bool flag = type == null;
+ if (flag)
+ {
+ type = value.GetType();
+ }
+ ProtoTypeCode typeCode = Helpers.GetTypeCode(type);
+ int num;
+ WireType wireType = this.GetWireType(typeCode, format, ref type, out num);
+ bool flag2 = num >= 0;
+ bool result;
+ if (flag2)
+ {
+ bool flag3 = Helpers.IsEnum(type);
+ if (flag3)
+ {
+ this.Serialize(num, value, writer);
+ result = true;
+ }
+ else
+ {
+ ProtoWriter.WriteFieldHeader(tag, wireType, writer);
+ WireType wireType2 = wireType;
+ if (wireType2 == WireType.None)
+ {
+ throw ProtoWriter.CreateException(writer);
+ }
+ if (wireType2 - WireType.String > 1)
+ {
+ this.Serialize(num, value, writer);
+ result = true;
+ }
+ else
+ {
+ SubItemToken token = ProtoWriter.StartSubItem(value, writer);
+ this.Serialize(num, value, writer);
+ ProtoWriter.EndSubItem(token, writer);
+ result = true;
+ }
+ }
+ }
+ else
+ {
+ bool flag4 = wireType != WireType.None;
+ if (flag4)
+ {
+ ProtoWriter.WriteFieldHeader(tag, wireType, writer);
+ }
+ ProtoTypeCode protoTypeCode = typeCode;
+ switch (protoTypeCode)
+ {
+ case ProtoTypeCode.Boolean:
+ ProtoWriter.WriteBoolean((bool)value, writer);
+ return true;
+ case ProtoTypeCode.Char:
+ ProtoWriter.WriteUInt16((ushort)((char)value), writer);
+ return true;
+ case ProtoTypeCode.SByte:
+ ProtoWriter.WriteSByte((sbyte)value, writer);
+ return true;
+ case ProtoTypeCode.Byte:
+ ProtoWriter.WriteByte((byte)value, writer);
+ return true;
+ case ProtoTypeCode.Int16:
+ ProtoWriter.WriteInt16((short)value, writer);
+ return true;
+ case ProtoTypeCode.UInt16:
+ ProtoWriter.WriteUInt16((ushort)value, writer);
+ return true;
+ case ProtoTypeCode.Int32:
+ ProtoWriter.WriteInt32((int)value, writer);
+ return true;
+ case ProtoTypeCode.UInt32:
+ ProtoWriter.WriteUInt32((uint)value, writer);
+ return true;
+ case ProtoTypeCode.Int64:
+ ProtoWriter.WriteInt64((long)value, writer);
+ return true;
+ case ProtoTypeCode.UInt64:
+ ProtoWriter.WriteUInt64((ulong)value, writer);
+ return true;
+ case ProtoTypeCode.Single:
+ ProtoWriter.WriteSingle((float)value, writer);
+ return true;
+ case ProtoTypeCode.Double:
+ ProtoWriter.WriteDouble((double)value, writer);
+ return true;
+ case ProtoTypeCode.Decimal:
+ BclHelpers.WriteDecimal((decimal)value, writer);
+ return true;
+ case ProtoTypeCode.DateTime:
+ BclHelpers.WriteDateTime((DateTime)value, writer);
+ return true;
+ case (ProtoTypeCode)17:
+ break;
+ case ProtoTypeCode.String:
+ ProtoWriter.WriteString((string)value, writer);
+ return true;
+ default:
+ switch (protoTypeCode)
+ {
+ case ProtoTypeCode.TimeSpan:
+ BclHelpers.WriteTimeSpan((TimeSpan)value, writer);
+ return true;
+ case ProtoTypeCode.ByteArray:
+ ProtoWriter.WriteBytes((byte[])value, writer);
+ return true;
+ case ProtoTypeCode.Guid:
+ BclHelpers.WriteGuid((Guid)value, writer);
+ return true;
+ case ProtoTypeCode.Uri:
+ ProtoWriter.WriteString(((Uri)value).AbsoluteUri, writer);
+ return true;
+ }
+ break;
+ }
+ Helpers.DebugAssert(wireType == WireType.None);
+ IEnumerable enumerable = value as IEnumerable;
+ bool flag5 = enumerable != null;
+ if (flag5)
+ {
+ if (isInsideList)
+ {
+ throw TypeModel.CreateNestedListsNotSupported();
+ }
+ foreach (object obj in enumerable)
+ {
+ bool flag6 = obj == null;
+ if (flag6)
+ {
+ throw new NullReferenceException();
+ }
+ bool flag7 = !this.TrySerializeAuxiliaryType(writer, null, format, tag, obj, true);
+ if (flag7)
+ {
+ TypeModel.ThrowUnexpectedType(obj.GetType());
+ }
+ }
+ result = true;
+ }
+ else
+ {
+ result = false;
+ }
+ }
+ return result;
+ }
+
+ private void SerializeCore(ProtoWriter writer, object value)
+ {
+ bool flag = value == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("value");
+ }
+ Type type = value.GetType();
+ int key = this.GetKey(ref type);
+ bool flag2 = key >= 0;
+ if (flag2)
+ {
+ this.Serialize(key, value, writer);
+ }
+ else
+ {
+ bool flag3 = !this.TrySerializeAuxiliaryType(writer, type, DataFormat.Default, 1, value, false);
+ if (flag3)
+ {
+ TypeModel.ThrowUnexpectedType(type);
+ }
+ }
+ }
+
+ public void Serialize(Stream dest, object value)
+ {
+ this.Serialize(dest, value, null);
+ }
+
+ public void Serialize(Stream dest, object value, SerializationContext context)
+ {
+ using (ProtoWriter protoWriter = new ProtoWriter(dest, this, context))
+ {
+ protoWriter.SetRootObject(value);
+ this.SerializeCore(protoWriter, value);
+ protoWriter.Close();
+ }
+ }
+
+ public void Serialize(ProtoWriter dest, object value)
+ {
+ bool flag = dest == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("dest");
+ }
+ dest.CheckDepthFlushlock();
+ dest.SetRootObject(value);
+ this.SerializeCore(dest, value);
+ dest.CheckDepthFlushlock();
+ ProtoWriter.Flush(dest);
+ }
+
+ public object DeserializeWithLengthPrefix(Stream source, object value, Type type, PrefixStyle style, int fieldNumber)
+ {
+ int num;
+ return this.DeserializeWithLengthPrefix(source, value, type, style, fieldNumber, null, out num);
+ }
+
+ public object DeserializeWithLengthPrefix(Stream source, object value, Type type, PrefixStyle style, int expectedField, Serializer.TypeResolver resolver)
+ {
+ int num;
+ return this.DeserializeWithLengthPrefix(source, value, type, style, expectedField, resolver, out num);
+ }
+
+ public object DeserializeWithLengthPrefix(Stream source, object value, Type type, PrefixStyle style, int expectedField, Serializer.TypeResolver resolver, out int bytesRead)
+ {
+ bool flag;
+ return this.DeserializeWithLengthPrefix(source, value, type, style, expectedField, resolver, out bytesRead, out flag, null);
+ }
+
+ private object DeserializeWithLengthPrefix(Stream source, object value, Type type, PrefixStyle style, int expectedField, Serializer.TypeResolver resolver, out int bytesRead, out bool haveObject, SerializationContext context)
+ {
+ haveObject = false;
+ bytesRead = 0;
+ bool flag = type == null && (style != PrefixStyle.Base128 || resolver == null);
+ if (flag)
+ {
+ throw new InvalidOperationException("A type must be provided unless base-128 prefixing is being used in combination with a resolver");
+ }
+ for (;;)
+ {
+ bool flag2 = expectedField > 0 || resolver != null;
+ int num2;
+ int num3;
+ int num = ProtoReader.ReadLengthPrefix(source, flag2, style, out num2, out num3);
+ bool flag3 = num3 == 0;
+ if (flag3)
+ {
+ break;
+ }
+ bytesRead += num3;
+ bool flag4 = num < 0;
+ if (flag4)
+ {
+ goto Block_6;
+ }
+ bool flag5;
+ if (style != PrefixStyle.Base128)
+ {
+ flag5 = false;
+ }
+ else
+ {
+ bool flag6 = flag2 && expectedField == 0 && type == null && resolver != null;
+ if (flag6)
+ {
+ type = resolver(num2);
+ flag5 = (type == null);
+ }
+ else
+ {
+ flag5 = (expectedField != num2);
+ }
+ }
+ bool flag7 = flag5;
+ if (flag7)
+ {
+ bool flag8 = num == int.MaxValue;
+ if (flag8)
+ {
+ goto Block_13;
+ }
+ ProtoReader.Seek(source, num, null);
+ bytesRead += num;
+ }
+ if (!flag5)
+ {
+ goto Block_14;
+ }
+ }
+ return value;
+ Block_6:
+ return value;
+ Block_13:
+ throw new InvalidOperationException();
+ Block_14:
+ ProtoReader protoReader = null;
+ object result;
+ try
+ {
+ int num = 0;//!
+ //int num;//!
+ protoReader = ProtoReader.Create(source, this, context, num);
+ int key = this.GetKey(ref type);
+ bool flag9 = key >= 0 && !Helpers.IsEnum(type);
+ if (flag9)
+ {
+ value = this.Deserialize(key, value, protoReader);
+ }
+ else
+ {
+ bool flag10 = !this.TryDeserializeAuxiliaryType(protoReader, DataFormat.Default, 1, type, ref value, true, false, true, false) && num != 0;
+ if (flag10)
+ {
+ TypeModel.ThrowUnexpectedType(type);
+ }
+ }
+ bytesRead += protoReader.Position;
+ haveObject = true;
+ result = value;
+ }
+ finally
+ {
+ ProtoReader.Recycle(protoReader);
+ }
+ return result;
+ }
+
+ public IEnumerable DeserializeItems(Stream source, Type type, PrefixStyle style, int expectedField, Serializer.TypeResolver resolver)
+ {
+ return this.DeserializeItems(source, type, style, expectedField, resolver, null);
+ }
+
+ public IEnumerable DeserializeItems(Stream source, Type type, PrefixStyle style, int expectedField, Serializer.TypeResolver resolver, SerializationContext context)
+ {
+ return new TypeModel.DeserializeItemsIterator(this, source, type, style, expectedField, resolver, context);
+ }
+
+ public IEnumerable<T> DeserializeItems<T>(Stream source, PrefixStyle style, int expectedField)
+ {
+ return this.DeserializeItems<T>(source, style, expectedField, null);
+ }
+
+ public IEnumerable<T> DeserializeItems<T>(Stream source, PrefixStyle style, int expectedField, SerializationContext context)
+ {
+ return new TypeModel.DeserializeItemsIterator<T>(this, source, style, expectedField, context);
+ }
+
+ public void SerializeWithLengthPrefix(Stream dest, object value, Type type, PrefixStyle style, int fieldNumber)
+ {
+ this.SerializeWithLengthPrefix(dest, value, type, style, fieldNumber, null);
+ }
+
+ public void SerializeWithLengthPrefix(Stream dest, object value, Type type, PrefixStyle style, int fieldNumber, SerializationContext context)
+ {
+ bool flag = type == null;
+ if (flag)
+ {
+ bool flag2 = value == null;
+ if (flag2)
+ {
+ throw new ArgumentNullException("value");
+ }
+ type = this.MapType(value.GetType());
+ }
+ int key = this.GetKey(ref type);
+ using (ProtoWriter protoWriter = new ProtoWriter(dest, this, context))
+ {
+ if (style != PrefixStyle.None)
+ {
+ if (style - PrefixStyle.Base128 > 2)
+ {
+ throw new ArgumentOutOfRangeException("style");
+ }
+ ProtoWriter.WriteObject(value, key, protoWriter, style, fieldNumber);
+ }
+ else
+ {
+ this.Serialize(key, value, protoWriter);
+ }
+ protoWriter.Close();
+ }
+ }
+
+ public object Deserialize(Stream source, object value, Type type)
+ {
+ return this.Deserialize(source, value, type, null);
+ }
+
+ public object Deserialize(Stream source, object value, Type type, SerializationContext context)
+ {
+ bool noAutoCreate = this.PrepareDeserialize(value, ref type);
+ ProtoReader protoReader = null;
+ object result;
+ try
+ {
+ protoReader = ProtoReader.Create(source, this, context, -1);
+ bool flag = value != null;
+ if (flag)
+ {
+ protoReader.SetRootObject(value);
+ }
+ object obj = this.DeserializeCore(protoReader, type, value, noAutoCreate);
+ protoReader.CheckFullyConsumed();
+ result = obj;
+ }
+ finally
+ {
+ ProtoReader.Recycle(protoReader);
+ }
+ return result;
+ }
+
+ private bool PrepareDeserialize(object value, ref Type type)
+ {
+ bool flag = type == null;
+ if (flag)
+ {
+ bool flag2 = value == null;
+ if (flag2)
+ {
+ throw new ArgumentNullException("type");
+ }
+ type = this.MapType(value.GetType());
+ }
+ bool result = true;
+ Type underlyingType = Helpers.GetUnderlyingType(type);
+ bool flag3 = underlyingType != null;
+ if (flag3)
+ {
+ type = underlyingType;
+ result = false;
+ }
+ return result;
+ }
+
+ public object Deserialize(Stream source, object value, Type type, int length)
+ {
+ return this.Deserialize(source, value, type, length, null);
+ }
+
+ public object Deserialize(Stream source, object value, Type type, int length, SerializationContext context)
+ {
+ bool noAutoCreate = this.PrepareDeserialize(value, ref type);
+ ProtoReader protoReader = null;
+ object result;
+ try
+ {
+ protoReader = ProtoReader.Create(source, this, context, length);
+ bool flag = value != null;
+ if (flag)
+ {
+ protoReader.SetRootObject(value);
+ }
+ object obj = this.DeserializeCore(protoReader, type, value, noAutoCreate);
+ protoReader.CheckFullyConsumed();
+ result = obj;
+ }
+ finally
+ {
+ ProtoReader.Recycle(protoReader);
+ }
+ return result;
+ }
+
+ public object Deserialize(ProtoReader source, object value, Type type)
+ {
+ bool flag = source == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("source");
+ }
+ bool noAutoCreate = this.PrepareDeserialize(value, ref type);
+ bool flag2 = value != null;
+ if (flag2)
+ {
+ source.SetRootObject(value);
+ }
+ object result = this.DeserializeCore(source, type, value, noAutoCreate);
+ source.CheckFullyConsumed();
+ return result;
+ }
+
+ private object DeserializeCore(ProtoReader reader, Type type, object value, bool noAutoCreate)
+ {
+ int key = this.GetKey(ref type);
+ bool flag = key >= 0 && !Helpers.IsEnum(type);
+ object result;
+ if (flag)
+ {
+ result = this.Deserialize(key, value, reader);
+ }
+ else
+ {
+ this.TryDeserializeAuxiliaryType(reader, DataFormat.Default, 1, type, ref value, true, false, noAutoCreate, false);
+ result = value;
+ }
+ return result;
+ }
+
+ internal static MethodInfo ResolveListAdd(TypeModel model, Type listType, Type itemType, out bool isList)
+ {
+ isList = model.MapType(TypeModel.ilist).IsAssignableFrom(listType);
+ Type[] array = new Type[]
+ {
+ itemType
+ };
+ MethodInfo instanceMethod = Helpers.GetInstanceMethod(listType, "Add", array);
+ bool flag = instanceMethod == null;
+ if (flag)
+ {
+ bool flag2 = listType.IsInterface && listType == model.MapType(typeof(IEnumerable<>)).MakeGenericType(array);
+ Type type = model.MapType(typeof(ICollection<>)).MakeGenericType(array);
+ bool flag3 = flag2 || type.IsAssignableFrom(listType);
+ if (flag3)
+ {
+ instanceMethod = Helpers.GetInstanceMethod(type, "Add", array);
+ }
+ }
+ bool flag4 = instanceMethod == null;
+ if (flag4)
+ {
+ foreach (Type type2 in listType.GetInterfaces())
+ {
+ bool flag5 = type2.Name == "IProducerConsumerCollection`1" && type2.IsGenericType && type2.GetGenericTypeDefinition().FullName == "System.Collections.Concurrent.IProducerConsumerCollection`1";
+ if (flag5)
+ {
+ instanceMethod = Helpers.GetInstanceMethod(type2, "TryAdd", array);
+ bool flag6 = instanceMethod != null;
+ if (flag6)
+ {
+ break;
+ }
+ }
+ }
+ }
+ bool flag7 = instanceMethod == null;
+ if (flag7)
+ {
+ array[0] = model.MapType(typeof(object));
+ instanceMethod = Helpers.GetInstanceMethod(listType, "Add", array);
+ }
+ bool flag8 = instanceMethod == null & isList;
+ if (flag8)
+ {
+ instanceMethod = Helpers.GetInstanceMethod(model.MapType(TypeModel.ilist), "Add", array);
+ }
+ return instanceMethod;
+ }
+
+ internal static Type GetListItemType(TypeModel model, Type listType)
+ {
+ Helpers.DebugAssert(listType != null);
+ bool flag = listType == model.MapType(typeof(string)) || listType.IsArray || !model.MapType(typeof(IEnumerable)).IsAssignableFrom(listType);
+ Type result;
+ if (flag)
+ {
+ result = null;
+ }
+ else
+ {
+ BasicList basicList = new BasicList();
+ foreach (MethodInfo methodInfo in listType.GetMethods())
+ {
+ bool flag2 = methodInfo.IsStatic || methodInfo.Name != "Add";
+ if (!flag2)
+ {
+ ParameterInfo[] parameters = methodInfo.GetParameters();
+ Type parameterType = null;
+ bool flag3 = parameters.Length == 1 && !basicList.Contains(parameterType = parameters[0].ParameterType);
+ if (flag3)
+ {
+ basicList.Add(parameterType);
+ }
+ }
+ }
+ string name = listType.Name;
+ bool flag4 = name != null && (name.IndexOf("Queue") >= 0 || name.IndexOf("Stack") >= 0);
+ bool flag5 = !flag4;
+ if (flag5)
+ {
+ TypeModel.TestEnumerableListPatterns(model, basicList, listType);
+ foreach (Type iType in listType.GetInterfaces())
+ {
+ TypeModel.TestEnumerableListPatterns(model, basicList, iType);
+ }
+ }
+ foreach (PropertyInfo propertyInfo in listType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
+ {
+ bool flag6 = propertyInfo.Name != "Item" || basicList.Contains(propertyInfo.PropertyType);
+ if (!flag6)
+ {
+ ParameterInfo[] indexParameters = propertyInfo.GetIndexParameters();
+ bool flag7 = indexParameters.Length != 1 || indexParameters[0].ParameterType != model.MapType(typeof(int));
+ if (!flag7)
+ {
+ basicList.Add(propertyInfo.PropertyType);
+ }
+ }
+ }
+ switch (basicList.Count)
+ {
+ case 0:
+ return null;
+ case 1:
+ return (Type)basicList[0];
+ case 2:
+ {
+ bool flag8 = TypeModel.CheckDictionaryAccessors(model, (Type)basicList[0], (Type)basicList[1]);
+ if (flag8)
+ {
+ return (Type)basicList[0];
+ }
+ bool flag9 = TypeModel.CheckDictionaryAccessors(model, (Type)basicList[1], (Type)basicList[0]);
+ if (flag9)
+ {
+ return (Type)basicList[1];
+ }
+ break;
+ }
+ }
+ result = null;
+ }
+ return result;
+ }
+
+ private static void TestEnumerableListPatterns(TypeModel model, BasicList candidates, Type iType)
+ {
+ bool isGenericType = iType.IsGenericType;
+ if (isGenericType)
+ {
+ Type genericTypeDefinition = iType.GetGenericTypeDefinition();
+ bool flag = genericTypeDefinition == model.MapType(typeof(IEnumerable<>)) || genericTypeDefinition == model.MapType(typeof(ICollection<>)) || genericTypeDefinition.FullName == "System.Collections.Concurrent.IProducerConsumerCollection`1";
+ if (flag)
+ {
+ Type[] genericArguments = iType.GetGenericArguments();
+ bool flag2 = !candidates.Contains(genericArguments[0]);
+ if (flag2)
+ {
+ candidates.Add(genericArguments[0]);
+ }
+ }
+ }
+ }
+
+ private static bool CheckDictionaryAccessors(TypeModel model, Type pair, Type value)
+ {
+ return pair.IsGenericType && pair.GetGenericTypeDefinition() == model.MapType(typeof(KeyValuePair<, >)) && pair.GetGenericArguments()[1] == value;
+ }
+
+ private bool TryDeserializeList(TypeModel model, ProtoReader reader, DataFormat format, int tag, Type listType, Type itemType, ref object value)
+ {
+ bool flag;
+ MethodInfo methodInfo = TypeModel.ResolveListAdd(model, listType, itemType, out flag);
+ bool flag2 = methodInfo == null;
+ if (flag2)
+ {
+ throw new NotSupportedException("Unknown list variant: " + listType.FullName);
+ }
+ bool result = false;
+ object obj = null;
+ IList list = value as IList;
+ object[] array = flag ? null : ProtoDecoratorBase.s_argsRead;
+ BasicList basicList = listType.IsArray ? new BasicList() : null;
+ while (this.TryDeserializeAuxiliaryType(reader, format, tag, itemType, ref obj, true, true, true, true))
+ {
+ result = true;
+ bool flag3 = value == null && basicList == null;
+ if (flag3)
+ {
+ value = TypeModel.CreateListInstance(listType, itemType);
+ list = (value as IList);
+ }
+ bool flag4 = list != null;
+ if (flag4)
+ {
+ list.Add(obj);
+ }
+ else
+ {
+ bool flag5 = basicList != null;
+ if (flag5)
+ {
+ basicList.Add(obj);
+ }
+ else
+ {
+ array[0] = obj;
+ methodInfo.Invoke(value, array);
+ }
+ }
+ obj = null;
+ }
+ bool flag6 = basicList != null;
+ if (flag6)
+ {
+ bool flag7 = value != null;
+ if (flag7)
+ {
+ bool flag8 = basicList.Count == 0;
+ if (!flag8)
+ {
+ Array array2 = (Array)value;
+ Array array3 = Array.CreateInstance(itemType, array2.Length + basicList.Count);
+ Array.Copy(array2, array3, array2.Length);
+ basicList.CopyTo(array3, array2.Length);
+ value = array3;
+ }
+ }
+ else
+ {
+ Array array3 = Array.CreateInstance(itemType, basicList.Count);
+ basicList.CopyTo(array3, 0);
+ value = array3;
+ }
+ }
+ return result;
+ }
+
+ private static object CreateListInstance(Type listType, Type itemType)
+ {
+ Type type = listType;
+ bool isArray = listType.IsArray;
+ object result;
+ if (isArray)
+ {
+ result = Array.CreateInstance(itemType, 0);
+ }
+ else
+ {
+ bool flag = !listType.IsClass || listType.IsAbstract || Helpers.GetConstructor(listType, Helpers.EmptyTypes, true) == null;
+ if (flag)
+ {
+ bool flag2 = false;
+ string fullName;
+ bool flag3 = listType.IsInterface && (fullName = listType.FullName) != null && fullName.IndexOf("Dictionary") >= 0;
+ if (flag3)
+ {
+ bool flag4 = listType.IsGenericType && listType.GetGenericTypeDefinition() == typeof(IDictionary<, >);
+ if (flag4)
+ {
+ Type[] genericArguments = listType.GetGenericArguments();
+ type = typeof(Dictionary<, >).MakeGenericType(genericArguments);
+ flag2 = true;
+ }
+ bool flag5 = !flag2 && listType == typeof(IDictionary);
+ if (flag5)
+ {
+ type = typeof(Hashtable);
+ flag2 = true;
+ }
+ }
+ bool flag6 = !flag2;
+ if (flag6)
+ {
+ type = typeof(List<>).MakeGenericType(new Type[]
+ {
+ itemType
+ });
+ flag2 = true;
+ }
+ bool flag7 = !flag2;
+ if (flag7)
+ {
+ type = typeof(ArrayList);
+ }
+ }
+ result = Activator.CreateInstance(type);
+ }
+ return result;
+ }
+
+ internal bool TryDeserializeAuxiliaryType(ProtoReader reader, DataFormat format, int tag, Type type, ref object value, bool skipOtherFields, bool asListItem, bool autoCreate, bool insideList)
+ {
+ bool flag = type == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("type");
+ }
+ ProtoTypeCode typeCode = Helpers.GetTypeCode(type);
+ int num;
+ WireType wireType = this.GetWireType(typeCode, format, ref type, out num);
+ bool flag2 = false;
+ bool flag3 = wireType == WireType.None;
+ if (flag3)
+ {
+ Type type2 = TypeModel.GetListItemType(this, type);
+ bool flag4 = type2 == null && type.IsArray && type.GetArrayRank() == 1 && type != typeof(byte[]);
+ if (flag4)
+ {
+ type2 = type.GetElementType();
+ }
+ bool flag5 = type2 != null;
+ if (flag5)
+ {
+ if (insideList)
+ {
+ throw TypeModel.CreateNestedListsNotSupported();
+ }
+ flag2 = this.TryDeserializeList(this, reader, format, tag, type, type2, ref value);
+ bool flag6 = !flag2 && autoCreate;
+ if (flag6)
+ {
+ value = TypeModel.CreateListInstance(type, type2);
+ }
+ return flag2;
+ }
+ else
+ {
+ TypeModel.ThrowUnexpectedType(type);
+ }
+ }
+ int num2;
+ for (;;)
+ {
+ bool flag7 = flag2 && asListItem;
+ if (flag7)
+ {
+ break;
+ }
+ num2 = reader.ReadFieldHeader();
+ bool flag8 = num2 <= 0;
+ if (flag8)
+ {
+ break;
+ }
+ bool flag9 = num2 != tag;
+ if (flag9)
+ {
+ if (!skipOtherFields)
+ {
+ goto IL_12E;
+ }
+ reader.SkipField();
+ }
+ else
+ {
+ flag2 = true;
+ reader.Hint(wireType);
+ bool flag10 = num >= 0;
+ if (flag10)
+ {
+ WireType wireType2 = wireType;
+ if (wireType2 - WireType.String > 1)
+ {
+ value = this.Deserialize(num, value, reader);
+ }
+ else
+ {
+ SubItemToken token = ProtoReader.StartSubItem(reader);
+ value = this.Deserialize(num, value, reader);
+ ProtoReader.EndSubItem(token, reader);
+ }
+ }
+ else
+ {
+ ProtoTypeCode protoTypeCode = typeCode;
+ switch (protoTypeCode)
+ {
+ case ProtoTypeCode.Boolean:
+ value = reader.ReadBoolean();
+ break;
+ case ProtoTypeCode.Char:
+ value = (char)reader.ReadUInt16();
+ break;
+ case ProtoTypeCode.SByte:
+ value = reader.ReadSByte();
+ break;
+ case ProtoTypeCode.Byte:
+ value = reader.ReadByte();
+ break;
+ case ProtoTypeCode.Int16:
+ value = reader.ReadInt16();
+ break;
+ case ProtoTypeCode.UInt16:
+ value = reader.ReadUInt16();
+ break;
+ case ProtoTypeCode.Int32:
+ value = reader.ReadInt32();
+ break;
+ case ProtoTypeCode.UInt32:
+ value = reader.ReadUInt32();
+ break;
+ case ProtoTypeCode.Int64:
+ value = reader.ReadInt64();
+ break;
+ case ProtoTypeCode.UInt64:
+ value = reader.ReadUInt64();
+ break;
+ case ProtoTypeCode.Single:
+ value = reader.ReadSingle();
+ break;
+ case ProtoTypeCode.Double:
+ value = reader.ReadDouble();
+ break;
+ case ProtoTypeCode.Decimal:
+ value = BclHelpers.ReadDecimal(reader);
+ break;
+ case ProtoTypeCode.DateTime:
+ value = BclHelpers.ReadDateTime(reader);
+ break;
+ case (ProtoTypeCode)17:
+ break;
+ case ProtoTypeCode.String:
+ value = reader.ReadString();
+ break;
+ default:
+ switch (protoTypeCode)
+ {
+ case ProtoTypeCode.TimeSpan:
+ value = BclHelpers.ReadTimeSpan(reader);
+ break;
+ case ProtoTypeCode.ByteArray:
+ value = ProtoReader.AppendBytes((byte[])value, reader);
+ break;
+ case ProtoTypeCode.Guid:
+ value = BclHelpers.ReadGuid(reader);
+ break;
+ case ProtoTypeCode.Uri:
+ value = new Uri(reader.ReadString());
+ break;
+ }
+ break;
+ }
+ }
+ }
+ }
+ goto IL_375;
+ IL_12E:
+ throw ProtoReader.AddErrorData(new InvalidOperationException("Expected field " + tag.ToString() + ", but found " + num2.ToString()), reader);
+ IL_375:
+ bool flag11 = !flag2 && !asListItem && autoCreate;
+ if (flag11)
+ {
+ bool flag12 = type != typeof(string);
+ if (flag12)
+ {
+ value = Activator.CreateInstance(type);
+ }
+ }
+ return flag2;
+ }
+
+ public static RuntimeTypeModel Create()
+ {
+ return new RuntimeTypeModel(false);
+ }
+
+ protected internal static Type ResolveProxies(Type type)
+ {
+ bool flag = type == null;
+ Type result;
+ if (flag)
+ {
+ result = null;
+ }
+ else
+ {
+ bool isGenericParameter = type.IsGenericParameter;
+ if (isGenericParameter)
+ {
+ result = null;
+ }
+ else
+ {
+ Type underlyingType = Helpers.GetUnderlyingType(type);
+ bool flag2 = underlyingType != null;
+ if (flag2)
+ {
+ result = underlyingType;
+ }
+ else
+ {
+ string fullName = type.FullName;
+ bool flag3 = fullName != null && fullName.StartsWith("System.Data.Entity.DynamicProxies.");
+ if (flag3)
+ {
+ result = type.BaseType;
+ }
+ else
+ {
+ Type[] interfaces = type.GetInterfaces();
+ for (int i = 0; i < interfaces.Length; i++)
+ {
+ string fullName2 = interfaces[i].FullName;
+ if (fullName2 == "NHibernate.Proxy.INHibernateProxy" || fullName2 == "NHibernate.Proxy.DynamicProxy.IProxy" || fullName2 == "NHibernate.Intercept.IFieldInterceptorAccessor")
+ {
+ return type.BaseType;
+ }
+ }
+ result = null;
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ public bool IsDefined(Type type)
+ {
+ return this.GetKey(ref type) >= 0;
+ }
+
+ protected internal int GetKey(ref Type type)
+ {
+ bool flag = type == null;
+ int result;
+ if (flag)
+ {
+ result = -1;
+ }
+ else
+ {
+ int keyImpl = this.GetKeyImpl(type);
+ bool flag2 = keyImpl < 0;
+ if (flag2)
+ {
+ Type type2 = TypeModel.ResolveProxies(type);
+ bool flag3 = type2 != null;
+ if (flag3)
+ {
+ type = type2;
+ keyImpl = this.GetKeyImpl(type);
+ }
+ }
+ result = keyImpl;
+ }
+ return result;
+ }
+
+ protected abstract int GetKeyImpl(Type type);
+
+ protected internal abstract void Serialize(int key, object value, ProtoWriter dest);
+
+ protected internal abstract object Deserialize(int key, object value, ProtoReader source);
+
+ public object DeepClone(object value)
+ {
+ bool flag = value == null;
+ object result;
+ if (flag)
+ {
+ result = null;
+ }
+ else
+ {
+ Type type = value.GetType();
+ int key = this.GetKey(ref type);
+ bool flag2 = key >= 0 && !Helpers.IsEnum(type);
+ if (flag2)
+ {
+ using (MemoryStream memoryStream = new MemoryStream())
+ {
+ using (ProtoWriter protoWriter = new ProtoWriter(memoryStream, this, null))
+ {
+ protoWriter.SetRootObject(value);
+ this.Serialize(key, value, protoWriter);
+ protoWriter.Close();
+ }
+ memoryStream.Position = 0L;
+ ProtoReader protoReader = null;
+ try
+ {
+ protoReader = ProtoReader.Create(memoryStream, this, null, -1);
+ return this.Deserialize(key, null, protoReader);
+ }
+ finally
+ {
+ ProtoReader.Recycle(protoReader);
+ }
+ }
+ }
+ bool flag3 = type == typeof(byte[]);
+ if (flag3)
+ {
+ byte[] array = (byte[])value;
+ byte[] array2 = new byte[array.Length];
+ Helpers.BlockCopy(array, 0, array2, 0, array.Length);
+ result = array2;
+ }
+ else
+ {
+ int num;
+ bool flag4 = this.GetWireType(Helpers.GetTypeCode(type), DataFormat.Default, ref type, out num) != WireType.None && num < 0;
+ if (flag4)
+ {
+ result = value;
+ }
+ else
+ {
+ using (MemoryStream memoryStream2 = new MemoryStream())
+ {
+ using (ProtoWriter protoWriter2 = new ProtoWriter(memoryStream2, this, null))
+ {
+ bool flag5 = !this.TrySerializeAuxiliaryType(protoWriter2, type, DataFormat.Default, 1, value, false);
+ if (flag5)
+ {
+ TypeModel.ThrowUnexpectedType(type);
+ }
+ protoWriter2.Close();
+ }
+ memoryStream2.Position = 0L;
+ ProtoReader reader = null;
+ try
+ {
+ reader = ProtoReader.Create(memoryStream2, this, null, -1);
+ value = null;
+ this.TryDeserializeAuxiliaryType(reader, DataFormat.Default, 1, type, ref value, true, false, true, false);
+ result = value;
+ }
+ finally
+ {
+ ProtoReader.Recycle(reader);
+ }
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ protected internal static void ThrowUnexpectedSubtype(Type expected, Type actual)
+ {
+ bool flag = expected != TypeModel.ResolveProxies(actual);
+ if (flag)
+ {
+ throw new InvalidOperationException("Unexpected sub-type: " + actual.FullName);
+ }
+ }
+
+ protected internal static void ThrowUnexpectedType(Type type)
+ {
+ string str = (type == null) ? "(unknown)" : type.FullName;
+ bool flag = type != null;
+ if (flag)
+ {
+ Type baseType = type.BaseType;
+ bool flag2 = baseType != null && baseType.IsGenericType && baseType.GetGenericTypeDefinition().Name == "GeneratedMessage`2";
+ if (flag2)
+ {
+ throw new InvalidOperationException("Are you mixing protobuf-net and protobuf-csharp-port? See http://stackoverflow.com/q/11564914; type: " + str);
+ }
+ }
+ throw new InvalidOperationException("Type is not expected, and no contract can be inferred: " + str);
+ }
+
+ internal static Exception CreateNestedListsNotSupported()
+ {
+ return new NotSupportedException("Nested or jagged lists and arrays are not supported");
+ }
+
+ public static void ThrowCannotCreateInstance(Type type)
+ {
+ throw new ProtoException("No parameterless constructor found for " + ((type == null) ? "(null)" : type.Name));
+ }
+
+ internal static string SerializeType(TypeModel model, Type type)
+ {
+ bool flag = model != null;
+ if (flag)
+ {
+ TypeFormatEventHandler dynamicTypeFormatting = model.DynamicTypeFormatting;
+ bool flag2 = dynamicTypeFormatting != null;
+ if (flag2)
+ {
+ TypeFormatEventArgs typeFormatEventArgs = new TypeFormatEventArgs(type);
+ dynamicTypeFormatting(model, typeFormatEventArgs);
+ bool flag3 = !Helpers.IsNullOrEmpty(typeFormatEventArgs.FormattedName);
+ if (flag3)
+ {
+ return typeFormatEventArgs.FormattedName;
+ }
+ }
+ }
+ return type.AssemblyQualifiedName;
+ }
+
+ internal static Type DeserializeType(TypeModel model, string value)
+ {
+ bool flag = model != null;
+ if (flag)
+ {
+ TypeFormatEventHandler dynamicTypeFormatting = model.DynamicTypeFormatting;
+ bool flag2 = dynamicTypeFormatting != null;
+ if (flag2)
+ {
+ TypeFormatEventArgs typeFormatEventArgs = new TypeFormatEventArgs(value);
+ dynamicTypeFormatting(model, typeFormatEventArgs);
+ bool flag3 = typeFormatEventArgs.Type != null;
+ if (flag3)
+ {
+ return typeFormatEventArgs.Type;
+ }
+ }
+ }
+ return Type.GetType(value);
+ }
+
+ public bool CanSerializeContractType(Type type)
+ {
+ return this.CanSerialize(type, false, true, true);
+ }
+
+ public bool CanSerialize(Type type)
+ {
+ return this.CanSerialize(type, true, true, true);
+ }
+
+ public bool CanSerializeBasicType(Type type)
+ {
+ return this.CanSerialize(type, true, false, true);
+ }
+
+ private bool CanSerialize(Type type, bool allowBasic, bool allowContract, bool allowLists)
+ {
+ bool flag = type == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("type");
+ }
+ Type underlyingType = Helpers.GetUnderlyingType(type);
+ bool flag2 = underlyingType != null;
+ if (flag2)
+ {
+ type = underlyingType;
+ }
+ ProtoTypeCode typeCode = Helpers.GetTypeCode(type);
+ ProtoTypeCode protoTypeCode = typeCode;
+ bool result;
+ if (protoTypeCode > ProtoTypeCode.Unknown)
+ {
+ result = allowBasic;
+ }
+ else
+ {
+ int key = this.GetKey(ref type);
+ bool flag3 = key >= 0;
+ if (flag3)
+ {
+ result = allowContract;
+ }
+ else
+ {
+ if (allowLists)
+ {
+ Type type2 = null;
+ bool isArray = type.IsArray;
+ if (isArray)
+ {
+ bool flag4 = type.GetArrayRank() == 1;
+ if (flag4)
+ {
+ type2 = type.GetElementType();
+ }
+ }
+ else
+ {
+ type2 = TypeModel.GetListItemType(this, type);
+ }
+ bool flag5 = type2 != null;
+ if (flag5)
+ {
+ return this.CanSerialize(type2, allowBasic, allowContract, false);
+ }
+ }
+ result = false;
+ }
+ }
+ return result;
+ }
+
+ public virtual string GetSchema(Type type)
+ {
+ throw new NotSupportedException();
+ }
+
+ internal virtual Type GetType(string fullName, Assembly context)
+ {
+ return TypeModel.ResolveKnownType(fullName, this, context);
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ internal static Type ResolveKnownType(string name, TypeModel model, Assembly assembly)
+ {
+ bool flag = Helpers.IsNullOrEmpty(name);
+ Type result;
+ if (flag)
+ {
+ result = null;
+ }
+ else
+ {
+ try
+ {
+ Type type = Type.GetType(name);
+ bool flag2 = type != null;
+ if (flag2)
+ {
+ return type;
+ }
+ }
+ catch
+ {
+ }
+ try
+ {
+ int num = name.IndexOf(',');
+ string name2 = ((num > 0) ? name.Substring(0, num) : name).Trim();
+ bool flag3 = assembly == null;
+ if (flag3)
+ {
+ assembly = Assembly.GetCallingAssembly();
+ }
+ Type type2 = (assembly == null) ? null : assembly.GetType(name2);
+ bool flag4 = type2 != null;
+ if (flag4)
+ {
+ return type2;
+ }
+ }
+ catch
+ {
+ }
+ result = null;
+ }
+ return result;
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/TypeModel.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/TypeModel.cs.meta new file mode 100644 index 00000000..71fa0af1 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/TypeModel.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: dbb3d0ca7c570e0439827efde10650ea +timeCreated: 1611404654 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/ValueMember.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/ValueMember.cs new file mode 100644 index 00000000..ec50b41a --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/ValueMember.cs @@ -0,0 +1,808 @@ +using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Reflection;
+using ProtoBuf.Serializers;
+
+namespace ProtoBuf.Meta
+{
+ public class ValueMember
+ {
+ public int FieldNumber
+ {
+ get
+ {
+ return this.fieldNumber;
+ }
+ }
+
+ public MemberInfo Member
+ {
+ get
+ {
+ return this.member;
+ }
+ }
+
+ public Type ItemType
+ {
+ get
+ {
+ return this.itemType;
+ }
+ }
+
+ public Type MemberType
+ {
+ get
+ {
+ return this.memberType;
+ }
+ }
+
+ public Type DefaultType
+ {
+ get
+ {
+ return this.defaultType;
+ }
+ }
+
+ public Type ParentType
+ {
+ get
+ {
+ return this.parentType;
+ }
+ }
+
+ public object DefaultValue
+ {
+ get
+ {
+ return this.defaultValue;
+ }
+ set
+ {
+ this.ThrowIfFrozen();
+ this.defaultValue = value;
+ }
+ }
+
+ internal IProtoSerializer Serializer
+ {
+ get
+ {
+ bool flag = this.serializer == null;
+ if (flag)
+ {
+ this.serializer = this.BuildSerializer();
+ }
+ return this.serializer;
+ }
+ }
+
+ public DataFormat DataFormat
+ {
+ get
+ {
+ return this.dataFormat;
+ }
+ set
+ {
+ this.ThrowIfFrozen();
+ this.dataFormat = value;
+ }
+ }
+
+ public bool IsStrict
+ {
+ get
+ {
+ return this.HasFlag(1);
+ }
+ set
+ {
+ this.SetFlag(1, value, true);
+ }
+ }
+
+ public bool IsPacked
+ {
+ get
+ {
+ return this.HasFlag(2);
+ }
+ set
+ {
+ this.SetFlag(2, value, true);
+ }
+ }
+
+ public bool OverwriteList
+ {
+ get
+ {
+ return this.HasFlag(8);
+ }
+ set
+ {
+ this.SetFlag(8, value, true);
+ }
+ }
+
+ public bool IsRequired
+ {
+ get
+ {
+ return this.HasFlag(4);
+ }
+ set
+ {
+ this.SetFlag(4, value, true);
+ }
+ }
+
+ public bool AsReference
+ {
+ get
+ {
+ return this.asReference;
+ }
+ set
+ {
+ this.ThrowIfFrozen();
+ this.asReference = value;
+ }
+ }
+
+ public bool DynamicType
+ {
+ get
+ {
+ return this.dynamicType;
+ }
+ set
+ {
+ this.ThrowIfFrozen();
+ this.dynamicType = value;
+ }
+ }
+
+ public string Name
+ {
+ get
+ {
+ return Helpers.IsNullOrEmpty(this.name) ? this.member.Name : this.name;
+ }
+ }
+
+ public bool SupportNull
+ {
+ get
+ {
+ return this.HasFlag(16);
+ }
+ set
+ {
+ this.SetFlag(16, value, true);
+ }
+ }
+
+ private readonly int fieldNumber;
+
+ private readonly MemberInfo member;
+
+ private readonly Type parentType;
+
+ private readonly Type itemType;
+
+ private readonly Type defaultType;
+
+ private readonly Type memberType;
+
+ private object defaultValue;
+
+ private readonly RuntimeTypeModel model;
+
+ private IProtoSerializer serializer;
+
+ private DataFormat dataFormat;
+
+ private bool asReference;
+
+ private bool dynamicType;
+
+ private MethodInfo getSpecified;
+
+ private MethodInfo setSpecified;
+
+ private string name;
+
+ private const byte OPTIONS_IsStrict = 1;
+
+ private const byte OPTIONS_IsPacked = 2;
+
+ private const byte OPTIONS_IsRequired = 4;
+
+ private const byte OPTIONS_OverwriteList = 8;
+
+ private const byte OPTIONS_SupportNull = 16;
+
+ private byte flags;
+
+ internal sealed class Comparer : IComparer, IComparer<ValueMember>
+ {
+ public static readonly ValueMember.Comparer Default = new ValueMember.Comparer();
+
+ public int Compare(object x, object y)
+ {
+ return this.Compare(x as ValueMember, y as ValueMember);
+ }
+
+ public int Compare(ValueMember x, ValueMember y)
+ {
+ bool flag = x == y;
+ int result;
+ if (flag)
+ {
+ result = 0;
+ }
+ else
+ {
+ bool flag2 = x == null;
+ if (flag2)
+ {
+ result = -1;
+ }
+ else
+ {
+ bool flag3 = y == null;
+ if (flag3)
+ {
+ result = 1;
+ }
+ else
+ {
+ result = x.FieldNumber.CompareTo(y.FieldNumber);
+ }
+ }
+ }
+ return result;
+ }
+ }
+
+ public ValueMember(RuntimeTypeModel model, Type parentType, int fieldNumber, MemberInfo member, Type memberType, Type itemType, Type defaultType, DataFormat dataFormat, object defaultValue) : this(model, fieldNumber, memberType, itemType, defaultType, dataFormat)
+ {
+ bool flag = member == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("member");
+ }
+ bool flag2 = parentType == null;
+ if (flag2)
+ {
+ throw new ArgumentNullException("parentType");
+ }
+ bool flag3 = fieldNumber < 1 && !Helpers.IsEnum(parentType);
+ if (flag3)
+ {
+ throw new ArgumentOutOfRangeException("fieldNumber");
+ }
+ this.member = member;
+ this.parentType = parentType;
+ bool flag4 = fieldNumber < 1 && !Helpers.IsEnum(parentType);
+ if (flag4)
+ {
+ throw new ArgumentOutOfRangeException("fieldNumber");
+ }
+ bool flag5 = defaultValue != null && model.MapType(defaultValue.GetType()) != memberType;
+ if (flag5)
+ {
+ defaultValue = ValueMember.ParseDefaultValue(memberType, defaultValue);
+ }
+ this.defaultValue = defaultValue;
+ MetaType metaType = model.FindWithoutAdd(memberType);
+ bool flag6 = metaType != null;
+ if (flag6)
+ {
+ this.asReference = metaType.AsReferenceDefault;
+ }
+ else
+ {
+ this.asReference = MetaType.GetAsReferenceDefault(model, memberType);
+ }
+ }
+
+ internal ValueMember(RuntimeTypeModel model, int fieldNumber, Type memberType, Type itemType, Type defaultType, DataFormat dataFormat)
+ {
+ bool flag = memberType == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("memberType");
+ }
+ bool flag2 = model == null;
+ if (flag2)
+ {
+ throw new ArgumentNullException("model");
+ }
+ this.fieldNumber = fieldNumber;
+ this.memberType = memberType;
+ this.itemType = itemType;
+ this.defaultType = defaultType;
+ this.model = model;
+ this.dataFormat = dataFormat;
+ }
+
+ internal object GetRawEnumValue()
+ {
+ return ((FieldInfo)this.member).GetRawConstantValue();
+ }
+
+ private static object ParseDefaultValue(Type type, object value)
+ {
+ Type underlyingType = Helpers.GetUnderlyingType(type);
+ bool flag = underlyingType != null;
+ if (flag)
+ {
+ type = underlyingType;
+ }
+ bool flag2 = value is string;
+ if (flag2)
+ {
+ string text = (string)value;
+ bool flag3 = Helpers.IsEnum(type);
+ if (flag3)
+ {
+ return Helpers.ParseEnum(type, text);
+ }
+ ProtoTypeCode typeCode = Helpers.GetTypeCode(type);
+ switch (typeCode)
+ {
+ case ProtoTypeCode.Boolean:
+ return bool.Parse(text);
+ case ProtoTypeCode.Char:
+ {
+ bool flag4 = text.Length == 1;
+ if (flag4)
+ {
+ return text[0];
+ }
+ throw new FormatException("Single character expected: \"" + text + "\"");
+ }
+ case ProtoTypeCode.SByte:
+ return sbyte.Parse(text, NumberStyles.Integer, CultureInfo.InvariantCulture);
+ case ProtoTypeCode.Byte:
+ return byte.Parse(text, NumberStyles.Integer, CultureInfo.InvariantCulture);
+ case ProtoTypeCode.Int16:
+ return short.Parse(text, NumberStyles.Any, CultureInfo.InvariantCulture);
+ case ProtoTypeCode.UInt16:
+ return ushort.Parse(text, NumberStyles.Any, CultureInfo.InvariantCulture);
+ case ProtoTypeCode.Int32:
+ return int.Parse(text, NumberStyles.Any, CultureInfo.InvariantCulture);
+ case ProtoTypeCode.UInt32:
+ return uint.Parse(text, NumberStyles.Any, CultureInfo.InvariantCulture);
+ case ProtoTypeCode.Int64:
+ return long.Parse(text, NumberStyles.Any, CultureInfo.InvariantCulture);
+ case ProtoTypeCode.UInt64:
+ return ulong.Parse(text, NumberStyles.Any, CultureInfo.InvariantCulture);
+ case ProtoTypeCode.Single:
+ return float.Parse(text, NumberStyles.Any, CultureInfo.InvariantCulture);
+ case ProtoTypeCode.Double:
+ return double.Parse(text, NumberStyles.Any, CultureInfo.InvariantCulture);
+ case ProtoTypeCode.Decimal:
+ return decimal.Parse(text, NumberStyles.Any, CultureInfo.InvariantCulture);
+ case ProtoTypeCode.DateTime:
+ return DateTime.Parse(text, CultureInfo.InvariantCulture);
+ case (ProtoTypeCode)17:
+ break;
+ case ProtoTypeCode.String:
+ return text;
+ default:
+ switch (typeCode)
+ {
+ case ProtoTypeCode.TimeSpan:
+ return TimeSpan.Parse(text);
+ case ProtoTypeCode.Guid:
+ return new Guid(text);
+ case ProtoTypeCode.Uri:
+ return text;
+ }
+ break;
+ }
+ }
+ bool flag5 = Helpers.IsEnum(type);
+ object result;
+ if (flag5)
+ {
+ result = Enum.ToObject(type, value);
+ }
+ else
+ {
+ result = Convert.ChangeType(value, type, CultureInfo.InvariantCulture);
+ }
+ return result;
+ }
+
+ public void SetSpecified(MethodInfo getSpecified, MethodInfo setSpecified)
+ {
+ bool flag = getSpecified != null;
+ if (flag)
+ {
+ bool flag2 = getSpecified.ReturnType != this.model.MapType(typeof(bool)) || getSpecified.IsStatic || getSpecified.GetParameters().Length != 0;
+ if (flag2)
+ {
+ throw new ArgumentException("Invalid pattern for checking member-specified", "getSpecified");
+ }
+ }
+ bool flag3 = setSpecified != null;
+ if (flag3)
+ {
+ ParameterInfo[] parameters;
+ bool flag4 = setSpecified.ReturnType != this.model.MapType(typeof(void)) || setSpecified.IsStatic || (parameters = setSpecified.GetParameters()).Length != 1 || parameters[0].ParameterType != this.model.MapType(typeof(bool));
+ if (flag4)
+ {
+ throw new ArgumentException("Invalid pattern for setting member-specified", "setSpecified");
+ }
+ }
+ this.ThrowIfFrozen();
+ this.getSpecified = getSpecified;
+ this.setSpecified = setSpecified;
+ }
+
+ private void ThrowIfFrozen()
+ {
+ bool flag = this.serializer != null;
+ if (flag)
+ {
+ throw new InvalidOperationException("The type cannot be changed once a serializer has been generated");
+ }
+ }
+
+ private IProtoSerializer BuildSerializer()
+ {
+ int opaqueToken = 0;
+ IProtoSerializer result;
+ try
+ {
+ this.model.TakeLock(ref opaqueToken);
+ Type type = (this.itemType == null) ? this.memberType : this.itemType;
+ WireType wireType;
+ IProtoSerializer protoSerializer = ValueMember.TryGetCoreSerializer(this.model, this.dataFormat, type, out wireType, this.asReference, this.dynamicType, this.OverwriteList, true);
+ bool flag = protoSerializer == null;
+ if (flag)
+ {
+ throw new InvalidOperationException("No serializer defined for type: " + type.FullName);
+ }
+ bool flag2 = this.itemType != null && this.SupportNull;
+ if (flag2)
+ {
+ bool isPacked = this.IsPacked;
+ if (isPacked)
+ {
+ throw new NotSupportedException("Packed encodings cannot support null values");
+ }
+ protoSerializer = new TagDecorator(1, wireType, this.IsStrict, protoSerializer);
+ protoSerializer = new NullDecorator(this.model, protoSerializer);
+ protoSerializer = new TagDecorator(this.fieldNumber, WireType.StartGroup, false, protoSerializer);
+ }
+ else
+ {
+ protoSerializer = new TagDecorator(this.fieldNumber, wireType, this.IsStrict, protoSerializer);
+ }
+ bool flag3 = this.itemType != null;
+ if (flag3)
+ {
+ Type type2 = this.SupportNull ? this.itemType : (Helpers.GetUnderlyingType(this.itemType) ?? this.itemType);
+ Helpers.DebugAssert(type2 == protoSerializer.ExpectedType, "Wrong type in the tail; expected {0}, received {1}", new object[]
+ {
+ protoSerializer.ExpectedType,
+ type2
+ });
+ bool isArray = this.memberType.IsArray;
+ if (isArray)
+ {
+ protoSerializer = new ArrayDecorator(this.model, protoSerializer, this.fieldNumber, this.IsPacked, wireType, this.memberType, this.OverwriteList, this.SupportNull);
+ }
+ else
+ {
+ protoSerializer = ListDecorator.Create(this.model, this.memberType, this.defaultType, protoSerializer, this.fieldNumber, this.IsPacked, wireType, this.member != null && PropertyDecorator.CanWrite(this.model, this.member), this.OverwriteList, this.SupportNull);
+ }
+ }
+ else
+ {
+ bool flag4 = this.defaultValue != null && !this.IsRequired && this.getSpecified == null;
+ if (flag4)
+ {
+ protoSerializer = new DefaultValueDecorator(this.model, this.defaultValue, protoSerializer);
+ }
+ }
+ bool flag5 = this.memberType == this.model.MapType(typeof(Uri));
+ if (flag5)
+ {
+ protoSerializer = new UriDecorator(this.model, protoSerializer);
+ }
+ bool flag6 = this.member != null;
+ if (flag6)
+ {
+ PropertyInfo propertyInfo = this.member as PropertyInfo;
+ bool flag7 = propertyInfo != null;
+ if (flag7)
+ {
+ protoSerializer = new PropertyDecorator(this.model, this.parentType, (PropertyInfo)this.member, protoSerializer);
+ }
+ else
+ {
+ FieldInfo fieldInfo = this.member as FieldInfo;
+ bool flag8 = fieldInfo != null;
+ if (!flag8)
+ {
+ throw new InvalidOperationException();
+ }
+ protoSerializer = new FieldDecorator(this.parentType, (FieldInfo)this.member, protoSerializer);
+ }
+ bool flag9 = this.getSpecified != null || this.setSpecified != null;
+ if (flag9)
+ {
+ protoSerializer = new MemberSpecifiedDecorator(this.getSpecified, this.setSpecified, protoSerializer);
+ }
+ }
+ result = protoSerializer;
+ }
+ finally
+ {
+ this.model.ReleaseLock(opaqueToken);
+ }
+ return result;
+ }
+
+ private static WireType GetIntWireType(DataFormat format, int width)
+ {
+ WireType result;
+ switch (format)
+ {
+ case DataFormat.Default:
+ case DataFormat.TwosComplement:
+ result = WireType.Variant;
+ break;
+ case DataFormat.ZigZag:
+ result = WireType.SignedVariant;
+ break;
+ case DataFormat.FixedSize:
+ result = ((width == 32) ? WireType.Fixed32 : WireType.Fixed64);
+ break;
+ default:
+ throw new InvalidOperationException();
+ }
+ return result;
+ }
+
+ private static WireType GetDateTimeWireType(DataFormat format)
+ {
+ switch (format)
+ {
+ case DataFormat.Default:
+ return WireType.String;
+ case DataFormat.FixedSize:
+ return WireType.Fixed64;
+ case DataFormat.Group:
+ return WireType.StartGroup;
+ }
+ throw new InvalidOperationException();
+ }
+
+ internal static IProtoSerializer TryGetCoreSerializer(RuntimeTypeModel model, DataFormat dataFormat, Type type, out WireType defaultWireType, bool asReference, bool dynamicType, bool overwriteList, bool allowComplexTypes)
+ {
+ Type underlyingType = Helpers.GetUnderlyingType(type);
+ bool flag = underlyingType != null;
+ if (flag)
+ {
+ type = underlyingType;
+ }
+ bool flag2 = Helpers.IsEnum(type);
+ IProtoSerializer result;
+ if (flag2)
+ {
+ bool flag3 = allowComplexTypes && model != null;
+ if (flag3)
+ {
+ defaultWireType = WireType.Variant;
+ result = new EnumSerializer(type, model.GetEnumMap(type));
+ }
+ else
+ {
+ defaultWireType = WireType.None;
+ result = null;
+ }
+ }
+ else
+ {
+ ProtoTypeCode typeCode = Helpers.GetTypeCode(type);
+ ProtoTypeCode protoTypeCode = typeCode;
+ switch (protoTypeCode)
+ {
+ case ProtoTypeCode.Boolean:
+ defaultWireType = WireType.Variant;
+ return new BooleanSerializer(model);
+ case ProtoTypeCode.Char:
+ defaultWireType = WireType.Variant;
+ return new CharSerializer(model);
+ case ProtoTypeCode.SByte:
+ defaultWireType = ValueMember.GetIntWireType(dataFormat, 32);
+ return new SByteSerializer(model);
+ case ProtoTypeCode.Byte:
+ defaultWireType = ValueMember.GetIntWireType(dataFormat, 32);
+ return new ByteSerializer(model);
+ case ProtoTypeCode.Int16:
+ defaultWireType = ValueMember.GetIntWireType(dataFormat, 32);
+ return new Int16Serializer(model);
+ case ProtoTypeCode.UInt16:
+ defaultWireType = ValueMember.GetIntWireType(dataFormat, 32);
+ return new UInt16Serializer(model);
+ case ProtoTypeCode.Int32:
+ defaultWireType = ValueMember.GetIntWireType(dataFormat, 32);
+ return new Int32Serializer(model);
+ case ProtoTypeCode.UInt32:
+ defaultWireType = ValueMember.GetIntWireType(dataFormat, 32);
+ return new UInt32Serializer(model);
+ case ProtoTypeCode.Int64:
+ defaultWireType = ValueMember.GetIntWireType(dataFormat, 64);
+ return new Int64Serializer(model);
+ case ProtoTypeCode.UInt64:
+ defaultWireType = ValueMember.GetIntWireType(dataFormat, 64);
+ return new UInt64Serializer(model);
+ case ProtoTypeCode.Single:
+ defaultWireType = WireType.Fixed32;
+ return new SingleSerializer(model);
+ case ProtoTypeCode.Double:
+ defaultWireType = WireType.Fixed64;
+ return new DoubleSerializer(model);
+ case ProtoTypeCode.Decimal:
+ defaultWireType = WireType.String;
+ return new DecimalSerializer(model);
+ case ProtoTypeCode.DateTime:
+ defaultWireType = ValueMember.GetDateTimeWireType(dataFormat);
+ return new DateTimeSerializer(model);
+ case (ProtoTypeCode)17:
+ break;
+ case ProtoTypeCode.String:
+ defaultWireType = WireType.String;
+ if (asReference)
+ {
+ return new NetObjectSerializer(model, model.MapType(typeof(string)), 0, BclHelpers.NetObjectOptions.AsReference);
+ }
+ return new StringSerializer(model);
+ default:
+ switch (protoTypeCode)
+ {
+ case ProtoTypeCode.TimeSpan:
+ defaultWireType = ValueMember.GetDateTimeWireType(dataFormat);
+ return new TimeSpanSerializer(model);
+ case ProtoTypeCode.ByteArray:
+ defaultWireType = WireType.String;
+ return new BlobSerializer(model, overwriteList);
+ case ProtoTypeCode.Guid:
+ defaultWireType = WireType.String;
+ return new GuidSerializer(model);
+ case ProtoTypeCode.Uri:
+ defaultWireType = WireType.String;
+ return new StringSerializer(model);
+ case ProtoTypeCode.Type:
+ defaultWireType = WireType.String;
+ return new SystemTypeSerializer(model);
+ }
+ break;
+ }
+ IProtoSerializer protoSerializer = model.AllowParseableTypes ? ParseableSerializer.TryCreate(type, model) : null;
+ bool flag4 = protoSerializer != null;
+ if (flag4)
+ {
+ defaultWireType = WireType.String;
+ result = protoSerializer;
+ }
+ else
+ {
+ bool flag5 = allowComplexTypes && model != null;
+ if (flag5)
+ {
+ int key = model.GetKey(type, false, true);
+ bool flag6 = asReference || dynamicType;
+ if (flag6)
+ {
+ defaultWireType = ((dataFormat == DataFormat.Group) ? WireType.StartGroup : WireType.String);
+ BclHelpers.NetObjectOptions netObjectOptions = BclHelpers.NetObjectOptions.None;
+ if (asReference)
+ {
+ netObjectOptions |= BclHelpers.NetObjectOptions.AsReference;
+ }
+ if (dynamicType)
+ {
+ netObjectOptions |= BclHelpers.NetObjectOptions.DynamicType;
+ }
+ bool flag7 = key >= 0;
+ if (flag7)
+ {
+ bool flag8 = asReference && Helpers.IsValueType(type);
+ if (flag8)
+ {
+ string text = "AsReference cannot be used with value-types";
+ bool flag9 = type.Name == "KeyValuePair`2";
+ if (flag9)
+ {
+ text += "; please see http://stackoverflow.com/q/14436606/";
+ }
+ else
+ {
+ text = text + ": " + type.FullName;
+ }
+ throw new InvalidOperationException(text);
+ }
+ MetaType metaType = model[type];
+ bool flag10 = asReference && metaType.IsAutoTuple;
+ if (flag10)
+ {
+ netObjectOptions |= BclHelpers.NetObjectOptions.LateSet;
+ }
+ bool useConstructor = metaType.UseConstructor;
+ if (useConstructor)
+ {
+ netObjectOptions |= BclHelpers.NetObjectOptions.UseConstructor;
+ }
+ }
+ return new NetObjectSerializer(model, type, key, netObjectOptions);
+ }
+ bool flag11 = key >= 0;
+ if (flag11)
+ {
+ defaultWireType = ((dataFormat == DataFormat.Group) ? WireType.StartGroup : WireType.String);
+ return new SubItemSerializer(type, key, model[type], true);
+ }
+ }
+ defaultWireType = WireType.None;
+ result = null;
+ }
+ }
+ return result;
+ }
+
+ internal void SetName(string name)
+ {
+ this.ThrowIfFrozen();
+ this.name = name;
+ }
+
+ private bool HasFlag(byte flag)
+ {
+ return (this.flags & flag) == flag;
+ }
+
+ private void SetFlag(byte flag, bool value, bool throwIfFrozen)
+ {
+ bool flag2 = throwIfFrozen && this.HasFlag(flag) != value;
+ if (flag2)
+ {
+ this.ThrowIfFrozen();
+ }
+ if (value)
+ {
+ this.flags |= flag;
+ }
+ else
+ {
+ this.flags &= (byte) ~flag;
+ }
+ }
+
+ internal string GetSchemaTypeName(bool applyNetObjectProxy, ref bool requiresBclImport)
+ {
+ Type type = this.ItemType;
+ bool flag = type == null;
+ if (flag)
+ {
+ type = this.MemberType;
+ }
+ return this.model.GetSchemaTypeName(type, this.DataFormat, applyNetObjectProxy && this.asReference, applyNetObjectProxy && this.dynamicType, ref requiresBclImport);
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/ValueMember.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/ValueMember.cs.meta new file mode 100644 index 00000000..a92dffc3 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Meta/ValueMember.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 20dcdd655bb536f4198cd99e27b58ded +timeCreated: 1611403409 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/NetObjectCache.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/NetObjectCache.cs new file mode 100644 index 00000000..be43372e --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/NetObjectCache.cs @@ -0,0 +1,256 @@ +using System;
+using System.Collections.Generic;
+using System.Runtime.CompilerServices;
+using ProtoBuf.Meta;
+
+namespace ProtoBuf
+{
+ internal sealed class NetObjectCache
+ {
+ private MutableList List
+ {
+ get
+ {
+ bool flag = this.underlyingList == null;
+ if (flag)
+ {
+ this.underlyingList = new MutableList();
+ }
+ return this.underlyingList;
+ }
+ }
+
+ internal const int Root = 0;
+
+ private MutableList underlyingList;
+
+ private object rootObject;
+
+ private int trapStartIndex;
+
+ private Dictionary<string, int> stringKeys;
+
+ private Dictionary<object, int> objectKeys;
+
+ private sealed class ReferenceComparer : IEqualityComparer<object>
+ {
+ public static readonly NetObjectCache.ReferenceComparer Default = new NetObjectCache.ReferenceComparer();
+
+ private ReferenceComparer()
+ {
+ }
+
+ bool IEqualityComparer<object>.Equals(object x, object y)
+ {
+ return x == y;
+ }
+
+ int IEqualityComparer<object>.GetHashCode(object obj)
+ {
+ return RuntimeHelpers.GetHashCode(obj);
+ }
+ }
+
+ internal object GetKeyedObject(int key)
+ {
+ bool flag = key-- == 0;
+ object result;
+ if (flag)
+ {
+ bool flag2 = this.rootObject == null;
+ if (flag2)
+ {
+ throw new ProtoException("No root object assigned");
+ }
+ result = this.rootObject;
+ }
+ else
+ {
+ BasicList list = this.List;
+ bool flag3 = key < 0 || key >= list.Count;
+ if (flag3)
+ {
+ Helpers.DebugWriteLine("Missing key: " + key);
+ throw new ProtoException("Internal error; a missing key occurred");
+ }
+ object obj = list[key];
+ bool flag4 = obj == null;
+ if (flag4)
+ {
+ throw new ProtoException("A deferred key does not have a value yet");
+ }
+ result = obj;
+ }
+ return result;
+ }
+
+ internal void SetKeyedObject(int key, object value)
+ {
+ bool flag = key-- == 0;
+ if (flag)
+ {
+ bool flag2 = value == null;
+ if (flag2)
+ {
+ throw new ArgumentNullException("value");
+ }
+ bool flag3 = this.rootObject != null && this.rootObject != value;
+ if (flag3)
+ {
+ throw new ProtoException("The root object cannot be reassigned");
+ }
+ this.rootObject = value;
+ }
+ else
+ {
+ MutableList list = this.List;
+ bool flag4 = key < list.Count;
+ if (flag4)
+ {
+ object obj = list[key];
+ bool flag5 = obj == null;
+ if (flag5)
+ {
+ list[key] = value;
+ }
+ else
+ {
+ bool flag6 = obj != value;
+ if (flag6)
+ {
+ throw new ProtoException("Reference-tracked objects cannot change reference");
+ }
+ }
+ }
+ else
+ {
+ bool flag7 = key != list.Add(value);
+ if (flag7)
+ {
+ throw new ProtoException("Internal error; a key mismatch occurred");
+ }
+ }
+ }
+ }
+
+ internal int AddObjectKey(object value, out bool existing)
+ {
+ bool flag = value == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("value");
+ }
+ bool flag2 = value == this.rootObject;
+ int result;
+ if (flag2)
+ {
+ existing = true;
+ result = 0;
+ }
+ else
+ {
+ string text = value as string;
+ BasicList list = this.List;
+ bool flag3 = text == null;
+ int num;
+ if (flag3)
+ {
+ bool flag4 = this.objectKeys == null;
+ if (flag4)
+ {
+ this.objectKeys = new Dictionary<object, int>(NetObjectCache.ReferenceComparer.Default);
+ num = -1;
+ }
+ else
+ {
+ bool flag5 = !this.objectKeys.TryGetValue(value, out num);
+ if (flag5)
+ {
+ num = -1;
+ }
+ }
+ }
+ else
+ {
+ bool flag6 = this.stringKeys == null;
+ if (flag6)
+ {
+ this.stringKeys = new Dictionary<string, int>();
+ num = -1;
+ }
+ else
+ {
+ bool flag7 = !this.stringKeys.TryGetValue(text, out num);
+ if (flag7)
+ {
+ num = -1;
+ }
+ }
+ }
+ bool flag8 = !(existing = (num >= 0));
+ if (flag8)
+ {
+ num = list.Add(value);
+ bool flag9 = text == null;
+ if (flag9)
+ {
+ this.objectKeys.Add(value, num);
+ }
+ else
+ {
+ this.stringKeys.Add(text, num);
+ }
+ }
+ result = num + 1;
+ }
+ return result;
+ }
+
+ internal void RegisterTrappedObject(object value)
+ {
+ bool flag = this.rootObject == null;
+ if (flag)
+ {
+ this.rootObject = value;
+ }
+ else
+ {
+ bool flag2 = this.underlyingList != null;
+ if (flag2)
+ {
+ for (int i = this.trapStartIndex; i < this.underlyingList.Count; i++)
+ {
+ this.trapStartIndex = i + 1;
+ bool flag3 = this.underlyingList[i] == null;
+ if (flag3)
+ {
+ this.underlyingList[i] = value;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ internal void Clear()
+ {
+ this.trapStartIndex = 0;
+ this.rootObject = null;
+ bool flag = this.underlyingList != null;
+ if (flag)
+ {
+ this.underlyingList.Clear();
+ }
+ bool flag2 = this.stringKeys != null;
+ if (flag2)
+ {
+ this.stringKeys.Clear();
+ }
+ bool flag3 = this.objectKeys != null;
+ if (flag3)
+ {
+ this.objectKeys.Clear();
+ }
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/NetObjectCache.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/NetObjectCache.cs.meta new file mode 100644 index 00000000..64065f90 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/NetObjectCache.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 951673a14fe33ba4cb5b5de3a81e0426 +timeCreated: 1611404179 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/PrefixStyle.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/PrefixStyle.cs new file mode 100644 index 00000000..d00f4b2e --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/PrefixStyle.cs @@ -0,0 +1,12 @@ +using System;
+
+namespace ProtoBuf
+{
+ public enum PrefixStyle
+ {
+ None,
+ Base128,
+ Fixed32,
+ Fixed32BigEndian
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/PrefixStyle.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/PrefixStyle.cs.meta new file mode 100644 index 00000000..d6e07821 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/PrefixStyle.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e73cfd14287fd634bae8eb6beeffd66d +timeCreated: 1611404748 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoAfterDeserializationAttribute.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoAfterDeserializationAttribute.cs new file mode 100644 index 00000000..7e79ce17 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoAfterDeserializationAttribute.cs @@ -0,0 +1,11 @@ +using System;
+using System.ComponentModel;
+
+namespace ProtoBuf
+{
+ [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
+ [ImmutableObject(true)]
+ public sealed class ProtoAfterDeserializationAttribute : Attribute
+ {
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoAfterDeserializationAttribute.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoAfterDeserializationAttribute.cs.meta new file mode 100644 index 00000000..81dc1255 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoAfterDeserializationAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 85a2871705ad3b84d913daf4c28cf09c +timeCreated: 1611404052 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoAfterSerializationAttribute.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoAfterSerializationAttribute.cs new file mode 100644 index 00000000..f6860f7e --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoAfterSerializationAttribute.cs @@ -0,0 +1,11 @@ +using System;
+using System.ComponentModel;
+
+namespace ProtoBuf
+{
+ [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
+ [ImmutableObject(true)]
+ public sealed class ProtoAfterSerializationAttribute : Attribute
+ {
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoAfterSerializationAttribute.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoAfterSerializationAttribute.cs.meta new file mode 100644 index 00000000..b98aacce --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoAfterSerializationAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c03da7f9ab4fe8047ac8833075c9a435 +timeCreated: 1611404485 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoBeforeDeserializationAttribute.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoBeforeDeserializationAttribute.cs new file mode 100644 index 00000000..4b1e2da0 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoBeforeDeserializationAttribute.cs @@ -0,0 +1,11 @@ +using System;
+using System.ComponentModel;
+
+namespace ProtoBuf
+{
+ [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
+ [ImmutableObject(true)]
+ public sealed class ProtoBeforeDeserializationAttribute : Attribute
+ {
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoBeforeDeserializationAttribute.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoBeforeDeserializationAttribute.cs.meta new file mode 100644 index 00000000..562df8c8 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoBeforeDeserializationAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4642fc0650246b8429aeeee38c911289 +timeCreated: 1611403649 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoBeforeSerializationAttribute.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoBeforeSerializationAttribute.cs new file mode 100644 index 00000000..eeb623d7 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoBeforeSerializationAttribute.cs @@ -0,0 +1,11 @@ +using System;
+using System.ComponentModel;
+
+namespace ProtoBuf
+{
+ [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
+ [ImmutableObject(true)]
+ public sealed class ProtoBeforeSerializationAttribute : Attribute
+ {
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoBeforeSerializationAttribute.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoBeforeSerializationAttribute.cs.meta new file mode 100644 index 00000000..8009606d --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoBeforeSerializationAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ecc2edf1ed394eb459ad04d80963ff0c +timeCreated: 1611404789 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoContractAttribute.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoContractAttribute.cs new file mode 100644 index 00000000..ee0e6152 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoContractAttribute.cs @@ -0,0 +1,194 @@ +using System;
+
+namespace ProtoBuf
+{
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Interface, AllowMultiple = false, Inherited = false)]
+ public sealed class ProtoContractAttribute : Attribute
+ {
+ public string Name
+ {
+ get
+ {
+ return this.name;
+ }
+ set
+ {
+ this.name = value;
+ }
+ }
+
+ public int ImplicitFirstTag
+ {
+ get
+ {
+ return this.implicitFirstTag;
+ }
+ set
+ {
+ bool flag = value < 1;
+ if (flag)
+ {
+ throw new ArgumentOutOfRangeException("ImplicitFirstTag");
+ }
+ this.implicitFirstTag = value;
+ }
+ }
+
+ public bool UseProtoMembersOnly
+ {
+ get
+ {
+ return this.HasFlag(4);
+ }
+ set
+ {
+ this.SetFlag(4, value);
+ }
+ }
+
+ public bool IgnoreListHandling
+ {
+ get
+ {
+ return this.HasFlag(16);
+ }
+ set
+ {
+ this.SetFlag(16, value);
+ }
+ }
+
+ public ImplicitFields ImplicitFields
+ {
+ get
+ {
+ return this.implicitFields;
+ }
+ set
+ {
+ this.implicitFields = value;
+ }
+ }
+
+ public bool InferTagFromName
+ {
+ get
+ {
+ return this.HasFlag(1);
+ }
+ set
+ {
+ this.SetFlag(1, value);
+ this.SetFlag(2, true);
+ }
+ }
+
+ internal bool InferTagFromNameHasValue
+ {
+ get
+ {
+ return this.HasFlag(2);
+ }
+ }
+
+ public int DataMemberOffset
+ {
+ get
+ {
+ return this.dataMemberOffset;
+ }
+ set
+ {
+ this.dataMemberOffset = value;
+ }
+ }
+
+ public bool SkipConstructor
+ {
+ get
+ {
+ return this.HasFlag(8);
+ }
+ set
+ {
+ this.SetFlag(8, value);
+ }
+ }
+
+ public bool AsReferenceDefault
+ {
+ get
+ {
+ return this.HasFlag(32);
+ }
+ set
+ {
+ this.SetFlag(32, value);
+ }
+ }
+
+ public bool EnumPassthru
+ {
+ get
+ {
+ return this.HasFlag(64);
+ }
+ set
+ {
+ this.SetFlag(64, value);
+ this.SetFlag(128, true);
+ }
+ }
+
+ internal bool EnumPassthruHasValue
+ {
+ get
+ {
+ return this.HasFlag(128);
+ }
+ }
+
+ private string name;
+
+ private int implicitFirstTag;
+
+ private ImplicitFields implicitFields;
+
+ private int dataMemberOffset;
+
+ private byte flags;
+
+ private const byte OPTIONS_InferTagFromName = 1;
+
+ private const byte OPTIONS_InferTagFromNameHasValue = 2;
+
+ private const byte OPTIONS_UseProtoMembersOnly = 4;
+
+ private const byte OPTIONS_SkipConstructor = 8;
+
+ private const byte OPTIONS_IgnoreListHandling = 16;
+
+ private const byte OPTIONS_AsReferenceDefault = 32;
+
+ private const byte OPTIONS_EnumPassthru = 64;
+
+ private const byte OPTIONS_EnumPassthruHasValue = 128;
+
+ private bool HasFlag(byte flag)
+ {
+ return (this.flags & flag) == flag;
+ }
+
+ private void SetFlag(byte flag, bool value)
+ {
+ if (value)
+ {
+ this.flags |= flag;
+ }
+ else
+ {
+ this.flags &= (byte)~flag;
+ }
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoContractAttribute.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoContractAttribute.cs.meta new file mode 100644 index 00000000..bdd12f5c --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoContractAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 757e2bbf79dd9494181d2d7761cb30be +timeCreated: 1611403947 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoConverterAttribute.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoConverterAttribute.cs new file mode 100644 index 00000000..2aea27a3 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoConverterAttribute.cs @@ -0,0 +1,9 @@ +using System;
+
+namespace ProtoBuf
+{
+ [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
+ public class ProtoConverterAttribute : Attribute
+ {
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoConverterAttribute.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoConverterAttribute.cs.meta new file mode 100644 index 00000000..f57b8fc4 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoConverterAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 63944827ef6f6e74b917e6c102af5910 +timeCreated: 1611403845 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoEnumAttribute.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoEnumAttribute.cs new file mode 100644 index 00000000..926a33c7 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoEnumAttribute.cs @@ -0,0 +1,44 @@ +using System;
+
+namespace ProtoBuf
+{
+ [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
+ public sealed class ProtoEnumAttribute : Attribute
+ {
+ public int Value
+ {
+ get
+ {
+ return this.enumValue;
+ }
+ set
+ {
+ this.enumValue = value;
+ this.hasValue = true;
+ }
+ }
+
+ public string Name
+ {
+ get
+ {
+ return this.name;
+ }
+ set
+ {
+ this.name = value;
+ }
+ }
+
+ private bool hasValue;
+
+ private int enumValue;
+
+ private string name;
+
+ public bool HasValue()
+ {
+ return this.hasValue;
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoEnumAttribute.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoEnumAttribute.cs.meta new file mode 100644 index 00000000..b087db5b --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoEnumAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2bb65995e007f6742878be5afc628d7b +timeCreated: 1611403500 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoException.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoException.cs new file mode 100644 index 00000000..975e48e4 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoException.cs @@ -0,0 +1,19 @@ +using System;
+
+namespace ProtoBuf
+{
+ public class ProtoException : Exception
+ {
+ public ProtoException()
+ {
+ }
+
+ public ProtoException(string message) : base(message)
+ {
+ }
+
+ public ProtoException(string message, Exception innerException) : base(message, innerException)
+ {
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoException.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoException.cs.meta new file mode 100644 index 00000000..4c5e796b --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoException.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a17e3b9814e9d2a4681a8464052a82b8 +timeCreated: 1611404253 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoIgnoreAttribute.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoIgnoreAttribute.cs new file mode 100644 index 00000000..bc3f0c50 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoIgnoreAttribute.cs @@ -0,0 +1,9 @@ +using System;
+
+namespace ProtoBuf
+{
+ [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
+ public class ProtoIgnoreAttribute : Attribute
+ {
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoIgnoreAttribute.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoIgnoreAttribute.cs.meta new file mode 100644 index 00000000..a68a8299 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoIgnoreAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2db07068e8e9a9d48948e00e0b551fe9 +timeCreated: 1611403507 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoIncludeAttribute.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoIncludeAttribute.cs new file mode 100644 index 00000000..020fb23c --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoIncludeAttribute.cs @@ -0,0 +1,73 @@ +using System;
+using System.ComponentModel;
+using ProtoBuf.Meta;
+
+namespace ProtoBuf
+{
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)]
+ public sealed class ProtoIncludeAttribute : Attribute
+ {
+ public int Tag
+ {
+ get
+ {
+ return this.tag;
+ }
+ }
+
+ public string KnownTypeName
+ {
+ get
+ {
+ return this.knownTypeName;
+ }
+ }
+
+ public Type KnownType
+ {
+ get
+ {
+ return TypeModel.ResolveKnownType(this.KnownTypeName, null, null);
+ }
+ }
+
+ [DefaultValue(DataFormat.Default)]
+ public DataFormat DataFormat
+ {
+ get
+ {
+ return this.dataFormat;
+ }
+ set
+ {
+ this.dataFormat = value;
+ }
+ }
+
+ private readonly int tag;
+
+ private readonly string knownTypeName;
+
+ private DataFormat dataFormat = DataFormat.Default;
+
+ public ProtoIncludeAttribute(int tag, Type knownType) : this(tag, (knownType == null) ? "" : knownType.AssemblyQualifiedName)
+ {
+ }
+
+ public ProtoIncludeAttribute(int tag, string knownTypeName)
+ {
+ bool flag = tag <= 0;
+ if (flag)
+ {
+ throw new ArgumentOutOfRangeException("tag", "Tags must be positive integers");
+ }
+ bool flag2 = Helpers.IsNullOrEmpty(knownTypeName);
+ if (flag2)
+ {
+ throw new ArgumentNullException("knownTypeName", "Known type cannot be blank");
+ }
+ this.tag = tag;
+ this.knownTypeName = knownTypeName;
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoIncludeAttribute.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoIncludeAttribute.cs.meta new file mode 100644 index 00000000..1ea6b8c6 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoIncludeAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f49c8ded347e5aa4d9490ab48c4ad8f8 +timeCreated: 1611404855 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoMemberAttribute.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoMemberAttribute.cs new file mode 100644 index 00000000..608b696e --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoMemberAttribute.cs @@ -0,0 +1,233 @@ +using System;
+using System.Reflection;
+
+namespace ProtoBuf
+{
+ [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
+ public class ProtoMemberAttribute : Attribute, IComparable, IComparable<ProtoMemberAttribute>
+ {
+ public string Name
+ {
+ get
+ {
+ return this.name;
+ }
+ set
+ {
+ this.name = value;
+ }
+ }
+
+ public DataFormat DataFormat
+ {
+ get
+ {
+ return this.dataFormat;
+ }
+ set
+ {
+ this.dataFormat = value;
+ }
+ }
+
+ public int Tag
+ {
+ get
+ {
+ return this.tag;
+ }
+ }
+
+ public bool IsRequired
+ {
+ get
+ {
+ return (this.options & MemberSerializationOptions.Required) == MemberSerializationOptions.Required;
+ }
+ set
+ {
+ if (value)
+ {
+ this.options |= MemberSerializationOptions.Required;
+ }
+ else
+ {
+ this.options &= ~MemberSerializationOptions.Required;
+ }
+ }
+ }
+
+ public bool IsPacked
+ {
+ get
+ {
+ return (this.options & MemberSerializationOptions.Packed) == MemberSerializationOptions.Packed;
+ }
+ set
+ {
+ if (value)
+ {
+ this.options |= MemberSerializationOptions.Packed;
+ }
+ else
+ {
+ this.options &= ~MemberSerializationOptions.Packed;
+ }
+ }
+ }
+
+ public bool OverwriteList
+ {
+ get
+ {
+ return (this.options & MemberSerializationOptions.OverwriteList) == MemberSerializationOptions.OverwriteList;
+ }
+ set
+ {
+ if (value)
+ {
+ this.options |= MemberSerializationOptions.OverwriteList;
+ }
+ else
+ {
+ this.options &= ~MemberSerializationOptions.OverwriteList;
+ }
+ }
+ }
+
+ public bool AsReference
+ {
+ get
+ {
+ return (this.options & MemberSerializationOptions.AsReference) == MemberSerializationOptions.AsReference;
+ }
+ set
+ {
+ if (value)
+ {
+ this.options |= MemberSerializationOptions.AsReference;
+ }
+ else
+ {
+ this.options &= ~MemberSerializationOptions.AsReference;
+ }
+ this.options |= MemberSerializationOptions.AsReferenceHasValue;
+ }
+ }
+
+ internal bool AsReferenceHasValue
+ {
+ get
+ {
+ return (this.options & MemberSerializationOptions.AsReferenceHasValue) == MemberSerializationOptions.AsReferenceHasValue;
+ }
+ set
+ {
+ if (value)
+ {
+ this.options |= MemberSerializationOptions.AsReferenceHasValue;
+ }
+ else
+ {
+ this.options &= ~MemberSerializationOptions.AsReferenceHasValue;
+ }
+ }
+ }
+
+ public bool DynamicType
+ {
+ get
+ {
+ return (this.options & MemberSerializationOptions.DynamicType) == MemberSerializationOptions.DynamicType;
+ }
+ set
+ {
+ if (value)
+ {
+ this.options |= MemberSerializationOptions.DynamicType;
+ }
+ else
+ {
+ this.options &= ~MemberSerializationOptions.DynamicType;
+ }
+ }
+ }
+
+ public MemberSerializationOptions Options
+ {
+ get
+ {
+ return this.options;
+ }
+ set
+ {
+ this.options = value;
+ }
+ }
+
+ internal MemberInfo Member;
+
+ internal bool TagIsPinned;
+
+ private string name;
+
+ private DataFormat dataFormat;
+
+ private int tag;
+
+ private MemberSerializationOptions options;
+
+ public int CompareTo(object other)
+ {
+ return this.CompareTo(other as ProtoMemberAttribute);
+ }
+
+ public int CompareTo(ProtoMemberAttribute other)
+ {
+ bool flag = other == null;
+ int result;
+ if (flag)
+ {
+ result = -1;
+ }
+ else
+ {
+ bool flag2 = this == other;
+ if (flag2)
+ {
+ result = 0;
+ }
+ else
+ {
+ int num = this.tag.CompareTo(other.tag);
+ bool flag3 = num == 0;
+ if (flag3)
+ {
+ num = string.CompareOrdinal(this.name, other.name);
+ }
+ result = num;
+ }
+ }
+ return result;
+ }
+
+ public ProtoMemberAttribute(int tag) : this(tag, false)
+ {
+ }
+
+ internal ProtoMemberAttribute(int tag, bool forced)
+ {
+ bool flag = tag <= 0 && !forced;
+ if (flag)
+ {
+ throw new ArgumentOutOfRangeException("tag");
+ }
+ this.tag = tag;
+ }
+
+ internal void Rebase(int tag)
+ {
+ this.tag = tag;
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoMemberAttribute.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoMemberAttribute.cs.meta new file mode 100644 index 00000000..11aa41da --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoMemberAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4ce9640748d13be458e0f9ec67e676c9 +timeCreated: 1611403693 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoPartialIgnoreAttribute.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoPartialIgnoreAttribute.cs new file mode 100644 index 00000000..86939880 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoPartialIgnoreAttribute.cs @@ -0,0 +1,28 @@ +using System;
+
+namespace ProtoBuf
+{
+ [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
+ public sealed class ProtoPartialIgnoreAttribute : ProtoIgnoreAttribute
+ {
+ public string MemberName
+ {
+ get
+ {
+ return this.memberName;
+ }
+ }
+
+ private readonly string memberName;
+
+ public ProtoPartialIgnoreAttribute(string memberName)
+ {
+ bool flag = Helpers.IsNullOrEmpty(memberName);
+ if (flag)
+ {
+ throw new ArgumentNullException("memberName");
+ }
+ this.memberName = memberName;
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoPartialIgnoreAttribute.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoPartialIgnoreAttribute.cs.meta new file mode 100644 index 00000000..e0c35110 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoPartialIgnoreAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 038d279d0054d4a4c944c48a509e1a43 +timeCreated: 1611402959 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoPartialMemberAttribute.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoPartialMemberAttribute.cs new file mode 100644 index 00000000..5c352c16 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoPartialMemberAttribute.cs @@ -0,0 +1,28 @@ +using System;
+
+namespace ProtoBuf
+{
+ [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
+ public sealed class ProtoPartialMemberAttribute : ProtoMemberAttribute
+ {
+ public string MemberName
+ {
+ get
+ {
+ return this.memberName;
+ }
+ }
+
+ private readonly string memberName;
+
+ public ProtoPartialMemberAttribute(int tag, string memberName) : base(tag)
+ {
+ bool flag = Helpers.IsNullOrEmpty(memberName);
+ if (flag)
+ {
+ throw new ArgumentNullException("memberName");
+ }
+ this.memberName = memberName;
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoPartialMemberAttribute.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoPartialMemberAttribute.cs.meta new file mode 100644 index 00000000..418e5806 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoPartialMemberAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4e83197626245624caf62b9555d960e9 +timeCreated: 1611403698 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoReader.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoReader.cs new file mode 100644 index 00000000..74daf36f --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoReader.cs @@ -0,0 +1,1838 @@ +using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using ProtoBuf.Meta;
+
+namespace ProtoBuf
+{
+ public sealed class ProtoReader : IDisposable
+ {
+ public int FieldNumber
+ {
+ get
+ {
+ return this.fieldNumber;
+ }
+ }
+
+ public WireType WireType
+ {
+ get
+ {
+ return this.wireType;
+ }
+ }
+
+ public bool InternStrings
+ {
+ get
+ {
+ return this.internStrings;
+ }
+ set
+ {
+ this.internStrings = value;
+ }
+ }
+
+ public SerializationContext Context
+ {
+ get
+ {
+ return this.context;
+ }
+ }
+
+ public int Position
+ {
+ get
+ {
+ return this.position;
+ }
+ }
+
+ public TypeModel Model
+ {
+ get
+ {
+ return this.model;
+ }
+ }
+
+ internal NetObjectCache NetCache
+ {
+ get
+ {
+ return this.netCache;
+ }
+ }
+
+ private Stream source;
+
+ private byte[] ioBuffer;
+
+ private TypeModel model;
+
+ private int fieldNumber;
+
+ private int depth;
+
+ private int dataRemaining;
+
+ private int ioIndex;
+
+ private int position;
+
+ private int available;
+
+ private int blockEnd;
+
+ private WireType wireType;
+
+ private bool isFixedLength;
+
+ private bool internStrings;
+
+ private NetObjectCache netCache;
+
+ private uint trapCount;
+
+ internal const int TO_EOF = -1;
+
+ private SerializationContext context;
+
+ private const long Int64Msb = -9223372036854775808L;
+
+ private const int Int32Msb = -2147483648;
+
+ private Dictionary<string, string> stringInterner;
+
+ private static readonly UTF8Encoding encoding = new UTF8Encoding();
+
+ private static readonly byte[] EmptyBlob = new byte[0];
+
+ [ThreadStatic]
+ private static ProtoReader lastReader;
+
+ public ProtoReader(Stream source, TypeModel model, SerializationContext context)
+ {
+ ProtoReader.Init(this, source, model, context, -1);
+ }
+
+ public ProtoReader(Stream source, TypeModel model, SerializationContext context, int length)
+ {
+ ProtoReader.Init(this, source, model, context, length);
+ }
+
+ private static void Init(ProtoReader reader, Stream source, TypeModel model, SerializationContext context, int length)
+ {
+ bool flag = source == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("source");
+ }
+ bool flag2 = !source.CanRead;
+ if (flag2)
+ {
+ throw new ArgumentException("Cannot read from stream", "source");
+ }
+ reader.source = source;
+ reader.ioBuffer = BufferPool.GetBuffer();
+ reader.model = model;
+ bool flag3 = length >= 0;
+ reader.isFixedLength = flag3;
+ reader.dataRemaining = (flag3 ? length : 0);
+ bool flag4 = context == null;
+ if (flag4)
+ {
+ context = SerializationContext.Default;
+ }
+ else
+ {
+ context.Freeze();
+ }
+ reader.context = context;
+ reader.position = (reader.available = (reader.depth = (reader.fieldNumber = (reader.ioIndex = 0))));
+ reader.blockEnd = int.MaxValue;
+ reader.internStrings = true;
+ reader.wireType = WireType.None;
+ reader.trapCount = 1u;
+ bool flag5 = reader.netCache == null;
+ if (flag5)
+ {
+ reader.netCache = new NetObjectCache();
+ }
+ }
+
+ public void Dispose()
+ {
+ this.source = null;
+ this.model = null;
+ BufferPool.ReleaseBufferToPool(ref this.ioBuffer);
+ bool flag = this.stringInterner != null;
+ if (flag)
+ {
+ this.stringInterner.Clear();
+ }
+ bool flag2 = this.netCache != null;
+ if (flag2)
+ {
+ this.netCache.Clear();
+ }
+ }
+
+ internal int TryReadUInt32VariantWithoutMoving(bool trimNegative, out uint value)
+ {
+ bool flag = this.available < 10;
+ if (flag)
+ {
+ this.Ensure(10, false);
+ }
+ bool flag2 = this.available == 0;
+ int result;
+ if (flag2)
+ {
+ value = 0u;
+ result = 0;
+ }
+ else
+ {
+ int num = this.ioIndex;
+ value = (uint)this.ioBuffer[num++];
+ bool flag3 = (value & 128u) == 0u;
+ if (flag3)
+ {
+ result = 1;
+ }
+ else
+ {
+ value &= 127u;
+ bool flag4 = this.available == 1;
+ if (flag4)
+ {
+ throw ProtoReader.EoF(this);
+ }
+ uint num2 = (uint)this.ioBuffer[num++];
+ value |= (num2 & 127u) << 7;
+ bool flag5 = (num2 & 128u) == 0u;
+ if (flag5)
+ {
+ result = 2;
+ }
+ else
+ {
+ bool flag6 = this.available == 2;
+ if (flag6)
+ {
+ throw ProtoReader.EoF(this);
+ }
+ num2 = (uint)this.ioBuffer[num++];
+ value |= (num2 & 127u) << 14;
+ bool flag7 = (num2 & 128u) == 0u;
+ if (flag7)
+ {
+ result = 3;
+ }
+ else
+ {
+ bool flag8 = this.available == 3;
+ if (flag8)
+ {
+ throw ProtoReader.EoF(this);
+ }
+ num2 = (uint)this.ioBuffer[num++];
+ value |= (num2 & 127u) << 21;
+ bool flag9 = (num2 & 128u) == 0u;
+ if (flag9)
+ {
+ result = 4;
+ }
+ else
+ {
+ bool flag10 = this.available == 4;
+ if (flag10)
+ {
+ throw ProtoReader.EoF(this);
+ }
+ num2 = (uint)this.ioBuffer[num];
+ value |= num2 << 28;
+ bool flag11 = (num2 & 240u) == 0u;
+ if (flag11)
+ {
+ result = 5;
+ }
+ else
+ {
+ bool flag12 = trimNegative && (num2 & 240u) == 240u && this.available >= 10 && this.ioBuffer[++num] == byte.MaxValue && this.ioBuffer[++num] == byte.MaxValue && this.ioBuffer[++num] == byte.MaxValue && this.ioBuffer[++num] == byte.MaxValue && this.ioBuffer[num + 1] == 1;
+ if (!flag12)
+ {
+ throw ProtoReader.AddErrorData(new OverflowException(), this);
+ }
+ result = 10;
+ }
+ }
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ private uint ReadUInt32Variant(bool trimNegative)
+ {
+ uint result;
+ int num = this.TryReadUInt32VariantWithoutMoving(trimNegative, out result);
+ bool flag = num > 0;
+ if (flag)
+ {
+ this.ioIndex += num;
+ this.available -= num;
+ this.position += num;
+ return result;
+ }
+ throw ProtoReader.EoF(this);
+ }
+
+ private bool TryReadUInt32Variant(out uint value)
+ {
+ int num = this.TryReadUInt32VariantWithoutMoving(false, out value);
+ bool flag = num > 0;
+ bool result;
+ if (flag)
+ {
+ this.ioIndex += num;
+ this.available -= num;
+ this.position += num;
+ result = true;
+ }
+ else
+ {
+ result = false;
+ }
+ return result;
+ }
+
+ public uint ReadUInt32()
+ {
+ WireType wireType = this.wireType;
+ uint result;
+ if (wireType != WireType.Variant)
+ {
+ if (wireType != WireType.Fixed64)
+ {
+ if (wireType != WireType.Fixed32)
+ {
+ throw this.CreateWireTypeException();
+ }
+ bool flag = this.available < 4;
+ if (flag)
+ {
+ this.Ensure(4, true);
+ }
+ this.position += 4;
+ this.available -= 4;
+ byte[] array = this.ioBuffer;
+ int num = this.ioIndex;
+ this.ioIndex = num + 1;
+ uint num2 = array[num];
+ byte[] array2 = this.ioBuffer;
+ num = this.ioIndex;
+ this.ioIndex = num + 1;
+ uint num3 = (uint)(num2 | array2[num] << 8);
+ byte[] array3 = this.ioBuffer;
+ num = this.ioIndex;
+ this.ioIndex = num + 1;
+ uint num4 = (uint)(num3 | array3[num] << 16);
+ byte[] array4 = this.ioBuffer;
+ num = this.ioIndex;
+ this.ioIndex = num + 1;
+ result = (uint)(num4 | array4[num] << 24);
+ }
+ else
+ {
+ ulong num5 = this.ReadUInt64();
+ result = checked((uint)num5);
+ }
+ }
+ else
+ {
+ result = this.ReadUInt32Variant(false);
+ }
+ return result;
+ }
+
+ internal void Ensure(int count, bool strict)
+ {
+ Helpers.DebugAssert(this.available <= count, "Asking for data without checking first");
+ bool flag = count > this.ioBuffer.Length;
+ if (flag)
+ {
+ BufferPool.ResizeAndFlushLeft(ref this.ioBuffer, count, this.ioIndex, this.available);
+ this.ioIndex = 0;
+ }
+ else
+ {
+ bool flag2 = this.ioIndex + count >= this.ioBuffer.Length;
+ if (flag2)
+ {
+ Helpers.BlockCopy(this.ioBuffer, this.ioIndex, this.ioBuffer, 0, this.available);
+ this.ioIndex = 0;
+ }
+ }
+ count -= this.available;
+ int num = this.ioIndex + this.available;
+ int num2 = this.ioBuffer.Length - num;
+ bool flag3 = this.isFixedLength;
+ if (flag3)
+ {
+ bool flag4 = this.dataRemaining < num2;
+ if (flag4)
+ {
+ num2 = this.dataRemaining;
+ }
+ }
+ int num3;
+ while (count > 0 && num2 > 0 && (num3 = this.source.Read(this.ioBuffer, num, num2)) > 0)
+ {
+ this.available += num3;
+ count -= num3;
+ num2 -= num3;
+ num += num3;
+ bool flag5 = this.isFixedLength;
+ if (flag5)
+ {
+ this.dataRemaining -= num3;
+ }
+ }
+ bool flag6 = strict && count > 0;
+ if (flag6)
+ {
+ throw ProtoReader.EoF(this);
+ }
+ }
+
+ public short ReadInt16()
+ {
+ return checked((short)this.ReadInt32());
+ }
+
+ public ushort ReadUInt16()
+ {
+ return checked((ushort)this.ReadUInt32());
+ }
+
+ public byte ReadByte()
+ {
+ return checked((byte)this.ReadUInt32());
+ }
+
+ public sbyte ReadSByte()
+ {
+ return checked((sbyte)this.ReadInt32());
+ }
+
+ public int ReadInt32()
+ {
+ WireType wireType = this.wireType;
+ if (wireType <= WireType.Fixed64)
+ {
+ if (wireType == WireType.Variant)
+ {
+ return (int)this.ReadUInt32Variant(true);
+ }
+ if (wireType == WireType.Fixed64)
+ {
+ long num = this.ReadInt64();
+ return checked((int)num);
+ }
+ }
+ else
+ {
+ if (wireType == WireType.Fixed32)
+ {
+ bool flag = this.available < 4;
+ if (flag)
+ {
+ this.Ensure(4, true);
+ }
+ this.position += 4;
+ this.available -= 4;
+ byte[] array = this.ioBuffer;
+ int num2 = this.ioIndex;
+ this.ioIndex = num2 + 1;
+ int num3 = array[num2];
+ byte[] array2 = this.ioBuffer;
+ num2 = this.ioIndex;
+ this.ioIndex = num2 + 1;
+ int num4 = num3 | array2[num2] << 8;
+ byte[] array3 = this.ioBuffer;
+ num2 = this.ioIndex;
+ this.ioIndex = num2 + 1;
+ int num5 = num4 | array3[num2] << 16;
+ byte[] array4 = this.ioBuffer;
+ num2 = this.ioIndex;
+ this.ioIndex = num2 + 1;
+ return num5 | array4[num2] << 24;
+ }
+ if (wireType == WireType.SignedVariant)
+ {
+ return ProtoReader.Zag(this.ReadUInt32Variant(true));
+ }
+ }
+ throw this.CreateWireTypeException();
+ }
+
+ private static int Zag(uint ziggedValue)
+ {
+ return (int)(-(ziggedValue & 1u) ^ (uint)((int)ziggedValue >> 1 & int.MaxValue));
+ }
+
+ private static long Zag(ulong ziggedValue)
+ {
+ //!
+ //return (long)(-(long)(ziggedValue & 1UL) ^ (ziggedValue >> 1 & 9223372036854775807UL));
+ long rightPart = (long)( ziggedValue >> 1 & long.MaxValue );
+ long leftPart = -(long)(ziggedValue & 1UL);
+ return leftPart ^ rightPart;
+ }
+
+ public long ReadInt64()
+ {
+ WireType wireType = this.wireType;
+ if (wireType <= WireType.Fixed64)
+ {
+ if (wireType == WireType.Variant)
+ {
+ return (long)this.ReadUInt64Variant();
+ }
+ if (wireType == WireType.Fixed64)
+ {
+ bool flag = this.available < 8;
+ if (flag)
+ {
+ this.Ensure(8, true);
+ }
+ this.position += 8;
+ this.available -= 8;
+ byte[] array = this.ioBuffer;
+ int num = this.ioIndex;
+ this.ioIndex = num + 1;
+ long num2 = (long)array[num];
+ byte[] array2 = this.ioBuffer;
+ num = this.ioIndex;
+ this.ioIndex = num + 1;
+ long num3 = num2 | (long)((long)array2[num] << 8);
+ byte[] array3 = this.ioBuffer;
+ num = this.ioIndex;
+ this.ioIndex = num + 1;
+ long num4 = num3 | (long)((long)array3[num] << 16);
+ byte[] array4 = this.ioBuffer;
+ num = this.ioIndex;
+ this.ioIndex = num + 1;
+ long num5 = num4 | (long)((long)array4[num] << 24);
+ byte[] array5 = this.ioBuffer;
+ num = this.ioIndex;
+ this.ioIndex = num + 1;
+ long num6 = num5 | (long)((long)array5[num] << 32);
+ byte[] array6 = this.ioBuffer;
+ num = this.ioIndex;
+ this.ioIndex = num + 1;
+ long num7 = num6 | (long)((long)array6[num] << 40);
+ byte[] array7 = this.ioBuffer;
+ num = this.ioIndex;
+ this.ioIndex = num + 1;
+ long num8 = num7 | (long)((long)array7[num] << 48);
+ byte[] array8 = this.ioBuffer;
+ num = this.ioIndex;
+ this.ioIndex = num + 1;
+ return num8 | (long)((long)array8[num] << 56);
+ }
+ }
+ else
+ {
+ if (wireType == WireType.Fixed32)
+ {
+ return (long)this.ReadInt32();
+ }
+ if (wireType == WireType.SignedVariant)
+ {
+ return ProtoReader.Zag(this.ReadUInt64Variant());
+ }
+ }
+ throw this.CreateWireTypeException();
+ }
+
+ private int TryReadUInt64VariantWithoutMoving(out ulong value)
+ {
+ bool flag = this.available < 10;
+ if (flag)
+ {
+ this.Ensure(10, false);
+ }
+ bool flag2 = this.available == 0;
+ int result;
+ if (flag2)
+ {
+ value = 0UL;
+ result = 0;
+ }
+ else
+ {
+ int num = this.ioIndex;
+ value = (ulong)this.ioBuffer[num++];
+ bool flag3 = (value & 128UL) == 0UL;
+ if (flag3)
+ {
+ result = 1;
+ }
+ else
+ {
+ value &= 127UL;
+ bool flag4 = this.available == 1;
+ if (flag4)
+ {
+ throw ProtoReader.EoF(this);
+ }
+ ulong num2 = (ulong)this.ioBuffer[num++];
+ value |= (num2 & 127UL) << 7;
+ bool flag5 = (num2 & 128UL) == 0UL;
+ if (flag5)
+ {
+ result = 2;
+ }
+ else
+ {
+ bool flag6 = this.available == 2;
+ if (flag6)
+ {
+ throw ProtoReader.EoF(this);
+ }
+ num2 = (ulong)this.ioBuffer[num++];
+ value |= (num2 & 127UL) << 14;
+ bool flag7 = (num2 & 128UL) == 0UL;
+ if (flag7)
+ {
+ result = 3;
+ }
+ else
+ {
+ bool flag8 = this.available == 3;
+ if (flag8)
+ {
+ throw ProtoReader.EoF(this);
+ }
+ num2 = (ulong)this.ioBuffer[num++];
+ value |= (num2 & 127UL) << 21;
+ bool flag9 = (num2 & 128UL) == 0UL;
+ if (flag9)
+ {
+ result = 4;
+ }
+ else
+ {
+ bool flag10 = this.available == 4;
+ if (flag10)
+ {
+ throw ProtoReader.EoF(this);
+ }
+ num2 = (ulong)this.ioBuffer[num++];
+ value |= (num2 & 127UL) << 28;
+ bool flag11 = (num2 & 128UL) == 0UL;
+ if (flag11)
+ {
+ result = 5;
+ }
+ else
+ {
+ bool flag12 = this.available == 5;
+ if (flag12)
+ {
+ throw ProtoReader.EoF(this);
+ }
+ num2 = (ulong)this.ioBuffer[num++];
+ value |= (num2 & 127UL) << 35;
+ bool flag13 = (num2 & 128UL) == 0UL;
+ if (flag13)
+ {
+ result = 6;
+ }
+ else
+ {
+ bool flag14 = this.available == 6;
+ if (flag14)
+ {
+ throw ProtoReader.EoF(this);
+ }
+ num2 = (ulong)this.ioBuffer[num++];
+ value |= (num2 & 127UL) << 42;
+ bool flag15 = (num2 & 128UL) == 0UL;
+ if (flag15)
+ {
+ result = 7;
+ }
+ else
+ {
+ bool flag16 = this.available == 7;
+ if (flag16)
+ {
+ throw ProtoReader.EoF(this);
+ }
+ num2 = (ulong)this.ioBuffer[num++];
+ value |= (num2 & 127UL) << 49;
+ bool flag17 = (num2 & 128UL) == 0UL;
+ if (flag17)
+ {
+ result = 8;
+ }
+ else
+ {
+ bool flag18 = this.available == 8;
+ if (flag18)
+ {
+ throw ProtoReader.EoF(this);
+ }
+ num2 = (ulong)this.ioBuffer[num++];
+ value |= (num2 & 127UL) << 56;
+ bool flag19 = (num2 & 128UL) == 0UL;
+ if (flag19)
+ {
+ result = 9;
+ }
+ else
+ {
+ bool flag20 = this.available == 9;
+ if (flag20)
+ {
+ throw ProtoReader.EoF(this);
+ }
+ num2 = (ulong)this.ioBuffer[num];
+ value |= num2 << 63;
+ bool flag21 = (num2 & 18446744073709551614UL) > 0UL;
+ if (flag21)
+ {
+ throw ProtoReader.AddErrorData(new OverflowException(), this);
+ }
+ result = 10;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ private ulong ReadUInt64Variant()
+ {
+ ulong result;
+ int num = this.TryReadUInt64VariantWithoutMoving(out result);
+ bool flag = num > 0;
+ if (flag)
+ {
+ this.ioIndex += num;
+ this.available -= num;
+ this.position += num;
+ return result;
+ }
+ throw ProtoReader.EoF(this);
+ }
+
+ private string Intern(string value)
+ {
+ bool flag = value == null;
+ string result;
+ if (flag)
+ {
+ result = null;
+ }
+ else
+ {
+ bool flag2 = value.Length == 0;
+ if (flag2)
+ {
+ result = "";
+ }
+ else
+ {
+ bool flag3 = this.stringInterner == null;
+ if (flag3)
+ {
+ this.stringInterner = new Dictionary<string, string>();
+ this.stringInterner.Add(value, value);
+ }
+ else
+ {
+ string text;
+ bool flag4 = this.stringInterner.TryGetValue(value, out text);
+ if (flag4)
+ {
+ value = text;
+ }
+ else
+ {
+ this.stringInterner.Add(value, value);
+ }
+ }
+ result = value;
+ }
+ }
+ return result;
+ }
+
+ public string ReadString()
+ {
+ bool flag = this.wireType == WireType.String;
+ if (flag)
+ {
+ int num = (int)this.ReadUInt32Variant(false);
+ bool flag2 = num == 0;
+ string result;
+ if (flag2)
+ {
+ result = "";
+ }
+ else
+ {
+ bool flag3 = this.available < num;
+ if (flag3)
+ {
+ this.Ensure(num, true);
+ }
+ string text = ProtoReader.encoding.GetString(this.ioBuffer, this.ioIndex, num);
+ bool flag4 = this.internStrings;
+ if (flag4)
+ {
+ text = this.Intern(text);
+ }
+ this.available -= num;
+ this.position += num;
+ this.ioIndex += num;
+ result = text;
+ }
+ return result;
+ }
+ throw this.CreateWireTypeException();
+ }
+
+ public void ThrowEnumException(Type type, int value)
+ {
+ string str = (type == null) ? "<null>" : type.FullName;
+ throw ProtoReader.AddErrorData(new ProtoException("No " + str + " enum is mapped to the wire-value " + value.ToString()), this);
+ }
+
+ private Exception CreateWireTypeException()
+ {
+ return this.CreateException("Invalid wire-type; this usually means you have over-written a file without truncating or setting the length; see http://stackoverflow.com/q/2152978/23354");
+ }
+
+ private Exception CreateException(string message)
+ {
+ return ProtoReader.AddErrorData(new ProtoException(message), this);
+ }
+
+ public unsafe double ReadDouble()
+ {
+ WireType wireType = this.wireType;
+ double result;
+ if (wireType != WireType.Fixed64)
+ {
+ if (wireType != WireType.Fixed32)
+ {
+ throw this.CreateWireTypeException();
+ }
+ result = (double)this.ReadSingle();
+ }
+ else
+ {
+ long num = this.ReadInt64();
+ result = *(double*)(&num);
+ }
+ return result;
+ }
+
+ public static object ReadObject(object value, int key, ProtoReader reader)
+ {
+ return ProtoReader.ReadTypedObject(value, key, reader, null);
+ }
+
+ internal static object ReadTypedObject(object value, int key, ProtoReader reader, Type type)
+ {
+ bool flag = reader.model == null;
+ if (flag)
+ {
+ throw ProtoReader.AddErrorData(new InvalidOperationException("Cannot deserialize sub-objects unless a model is provided"), reader);
+ }
+ SubItemToken token = ProtoReader.StartSubItem(reader);
+ bool flag2 = key >= 0;
+ if (flag2)
+ {
+ value = reader.model.Deserialize(key, value, reader);
+ }
+ else
+ {
+ bool flag3 = type != null && reader.model.TryDeserializeAuxiliaryType(reader, DataFormat.Default, 1, type, ref value, true, false, true, false);
+ if (!flag3)
+ {
+ TypeModel.ThrowUnexpectedType(type);
+ }
+ }
+ ProtoReader.EndSubItem(token, reader);
+ return value;
+ }
+
+ public static void EndSubItem(SubItemToken token, ProtoReader reader)
+ {
+ bool flag = reader == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("reader");
+ }
+ int value = token.value;
+ WireType wireType = reader.wireType;
+ if (wireType != WireType.EndGroup)
+ {
+ bool flag2 = value < reader.position;
+ if (flag2)
+ {
+ throw reader.CreateException("Sub-message not read entirely");
+ }
+ bool flag3 = reader.blockEnd != reader.position && reader.blockEnd != int.MaxValue;
+ if (flag3)
+ {
+ throw reader.CreateException("Sub-message not read correctly");
+ }
+ reader.blockEnd = value;
+ reader.depth--;
+ }
+ else
+ {
+ bool flag4 = value >= 0;
+ if (flag4)
+ {
+ throw ProtoReader.AddErrorData(new ArgumentException("token"), reader);
+ }
+ bool flag5 = -value != reader.fieldNumber;
+ if (flag5)
+ {
+ throw reader.CreateException("Wrong group was ended");
+ }
+ reader.wireType = WireType.None;
+ reader.depth--;
+ }
+ }
+
+ public static SubItemToken StartSubItem(ProtoReader reader)
+ {
+ bool flag = reader == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("reader");
+ }
+ WireType wireType = reader.wireType;
+ SubItemToken result;
+ if (wireType != WireType.String)
+ {
+ if (wireType != WireType.StartGroup)
+ {
+ throw reader.CreateWireTypeException();
+ }
+ reader.wireType = WireType.None;
+ reader.depth++;
+ result = new SubItemToken(-reader.fieldNumber);
+ }
+ else
+ {
+ int num = (int)reader.ReadUInt32Variant(false);
+ bool flag2 = num < 0;
+ if (flag2)
+ {
+ throw ProtoReader.AddErrorData(new InvalidOperationException(), reader);
+ }
+ int value = reader.blockEnd;
+ reader.blockEnd = reader.position + num;
+ reader.depth++;
+ result = new SubItemToken(value);
+ }
+ return result;
+ }
+
+ public int ReadFieldHeader()
+ {
+ bool flag = this.blockEnd <= this.position || this.wireType == WireType.EndGroup;
+ int result;
+ if (flag)
+ {
+ result = 0;
+ }
+ else
+ {
+ uint num;
+ bool flag2 = this.TryReadUInt32Variant(out num);
+ if (flag2)
+ {
+ this.wireType = (WireType)(num & 7u);
+ this.fieldNumber = (int)(num >> 3);
+ bool flag3 = this.fieldNumber < 1;
+ if (flag3)
+ {
+ throw new ProtoException("Invalid field in source data: " + this.fieldNumber.ToString());
+ }
+ }
+ else
+ {
+ this.wireType = WireType.None;
+ this.fieldNumber = 0;
+ }
+ bool flag4 = this.wireType == WireType.EndGroup;
+ if (flag4)
+ {
+ bool flag5 = this.depth > 0;
+ if (!flag5)
+ {
+ throw new ProtoException("Unexpected end-group in source data; this usually means the source data is corrupt");
+ }
+ result = 0;
+ }
+ else
+ {
+ result = this.fieldNumber;
+ }
+ }
+ return result;
+ }
+
+ public bool TryReadFieldHeader(int field)
+ {
+ bool flag = this.blockEnd <= this.position || this.wireType == WireType.EndGroup;
+ bool result;
+ if (flag)
+ {
+ result = false;
+ }
+ else
+ {
+ uint num2;
+ int num = this.TryReadUInt32VariantWithoutMoving(false, out num2);
+ WireType wireType = WireType.None;
+ bool flag2 = num > 0 && (int)num2 >> 3 == field && (wireType = (WireType)(num2 & 7u)) != WireType.EndGroup;
+ if (flag2)
+ {
+ this.wireType = wireType;
+ this.fieldNumber = field;
+ this.position += num;
+ this.ioIndex += num;
+ this.available -= num;
+ result = true;
+ }
+ else
+ {
+ result = false;
+ }
+ }
+ return result;
+ }
+
+ public void Hint(WireType wireType)
+ {
+ bool flag = this.wireType == wireType;
+ if (!flag)
+ {
+ bool flag2 = (wireType & (WireType)7) == this.wireType;
+ if (flag2)
+ {
+ this.wireType = wireType;
+ }
+ }
+ }
+
+ public void Assert(WireType wireType)
+ {
+ bool flag = this.wireType == wireType;
+ if (!flag)
+ {
+ bool flag2 = (wireType & (WireType)7) == this.wireType;
+ if (!flag2)
+ {
+ throw this.CreateWireTypeException();
+ }
+ this.wireType = wireType;
+ }
+ }
+
+ public void SkipField()
+ {
+ switch (this.wireType)
+ {
+ case WireType.Variant:
+ case WireType.SignedVariant:
+ this.ReadUInt64Variant();
+ return;
+ case WireType.Fixed64:
+ {
+ bool flag = this.available < 8;
+ if (flag)
+ {
+ this.Ensure(8, true);
+ }
+ this.available -= 8;
+ this.ioIndex += 8;
+ this.position += 8;
+ return;
+ }
+ case WireType.String:
+ {
+ int num = (int)this.ReadUInt32Variant(false);
+ bool flag2 = num <= this.available;
+ if (flag2)
+ {
+ this.available -= num;
+ this.ioIndex += num;
+ this.position += num;
+ return;
+ }
+ this.position += num;
+ num -= this.available;
+ this.ioIndex = (this.available = 0);
+ bool flag3 = this.isFixedLength;
+ if (flag3)
+ {
+ bool flag4 = num > this.dataRemaining;
+ if (flag4)
+ {
+ throw ProtoReader.EoF(this);
+ }
+ this.dataRemaining -= num;
+ }
+ ProtoReader.Seek(this.source, num, this.ioBuffer);
+ return;
+ }
+ case WireType.StartGroup:
+ {
+ int num2 = this.fieldNumber;
+ this.depth++;
+ while (this.ReadFieldHeader() > 0)
+ {
+ this.SkipField();
+ }
+ this.depth--;
+ bool flag5 = this.wireType == WireType.EndGroup && this.fieldNumber == num2;
+ if (flag5)
+ {
+ this.wireType = WireType.None;
+ return;
+ }
+ throw this.CreateWireTypeException();
+ }
+ case WireType.Fixed32:
+ {
+ bool flag6 = this.available < 4;
+ if (flag6)
+ {
+ this.Ensure(4, true);
+ }
+ this.available -= 4;
+ this.ioIndex += 4;
+ this.position += 4;
+ return;
+ }
+ }
+ throw this.CreateWireTypeException();
+ }
+
+ public ulong ReadUInt64()
+ {
+ WireType wireType = this.wireType;
+ ulong result;
+ if (wireType != WireType.Variant)
+ {
+ if (wireType != WireType.Fixed64)
+ {
+ if (wireType != WireType.Fixed32)
+ {
+ throw this.CreateWireTypeException();
+ }
+ result = (ulong)this.ReadUInt32();
+ }
+ else
+ {
+ bool flag = this.available < 8;
+ if (flag)
+ {
+ this.Ensure(8, true);
+ }
+ this.position += 8;
+ this.available -= 8;
+ byte[] array = this.ioBuffer;
+ int num = this.ioIndex;
+ this.ioIndex = num + 1;
+ ulong num2 = array[num];
+ byte[] array2 = this.ioBuffer;
+ num = this.ioIndex;
+ this.ioIndex = num + 1;
+ ulong num3 = num2 | (ulong) ( array2[num] << 8);
+ byte[] array3 = this.ioBuffer;
+ num = this.ioIndex;
+ this.ioIndex = num + 1;
+ ulong num4 = num3 | (ulong) (array3[num] << 16);
+ byte[] array4 = this.ioBuffer;
+ num = this.ioIndex;
+ this.ioIndex = num + 1;
+ ulong num5 = num4 | (ulong) ( array4[num] << 24);
+ byte[] array5 = this.ioBuffer;
+ num = this.ioIndex;
+ this.ioIndex = num + 1;
+ ulong num6 = num5 | (ulong)(array5[num] << 32);
+ byte[] array6 = this.ioBuffer;
+ num = this.ioIndex;
+ this.ioIndex = num + 1;
+ ulong num7 = num6 | (ulong)( array6[num] << 40);
+ byte[] array7 = this.ioBuffer;
+ num = this.ioIndex;
+ this.ioIndex = num + 1;
+ ulong num8 = num7 | (ulong)(array7[num] << 48);
+ byte[] array8 = this.ioBuffer;
+ num = this.ioIndex;
+ this.ioIndex = num + 1;
+ result = (num8 | (ulong) ( array8[num] << 56));
+ }
+ }
+ else
+ {
+ result = this.ReadUInt64Variant();
+ }
+ return result;
+ }
+
+ public unsafe float ReadSingle()
+ {
+ WireType wireType = this.wireType;
+ float result;
+ if (wireType != WireType.Fixed64)
+ {
+ if (wireType != WireType.Fixed32)
+ {
+ throw this.CreateWireTypeException();
+ }
+ int num = this.ReadInt32();
+ result = *(float*)(&num);
+ }
+ else
+ {
+ double num2 = this.ReadDouble();
+ float num3 = (float)num2;
+ bool flag = Helpers.IsInfinity(num3) && !Helpers.IsInfinity(num2);
+ if (flag)
+ {
+ throw ProtoReader.AddErrorData(new OverflowException(), this);
+ }
+ result = num3;
+ }
+ return result;
+ }
+
+ public bool ReadBoolean()
+ {
+ uint num = this.ReadUInt32();
+ bool result;
+ if (num != 0u)
+ {
+ if (num != 1u)
+ {
+ throw this.CreateException("Unexpected boolean value");
+ }
+ result = true;
+ }
+ else
+ {
+ result = false;
+ }
+ return result;
+ }
+
+ public static byte[] AppendBytes(byte[] value, ProtoReader reader)
+ {
+ bool flag = reader == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("reader");
+ }
+ WireType wireType = reader.wireType;
+ if (wireType != WireType.String)
+ {
+ throw reader.CreateWireTypeException();
+ }
+ int i = (int)reader.ReadUInt32Variant(false);
+ reader.wireType = WireType.None;
+ bool flag2 = i == 0;
+ byte[] result;
+ if (flag2)
+ {
+ result = ((value == null) ? ProtoReader.EmptyBlob : value);
+ }
+ else
+ {
+ bool flag3 = value == null || value.Length == 0;
+ int num;
+ if (flag3)
+ {
+ num = 0;
+ value = new byte[i];
+ }
+ else
+ {
+ num = value.Length;
+ byte[] array = new byte[value.Length + i];
+ Helpers.BlockCopy(value, 0, array, 0, value.Length);
+ value = array;
+ }
+ reader.position += i;
+ while (i > reader.available)
+ {
+ bool flag4 = reader.available > 0;
+ if (flag4)
+ {
+ Helpers.BlockCopy(reader.ioBuffer, reader.ioIndex, value, num, reader.available);
+ i -= reader.available;
+ num += reader.available;
+ reader.ioIndex = (reader.available = 0);
+ }
+ int num2 = (i > reader.ioBuffer.Length) ? reader.ioBuffer.Length : i;
+ bool flag5 = num2 > 0;
+ if (flag5)
+ {
+ reader.Ensure(num2, true);
+ }
+ }
+ bool flag6 = i > 0;
+ if (flag6)
+ {
+ Helpers.BlockCopy(reader.ioBuffer, reader.ioIndex, value, num, i);
+ reader.ioIndex += i;
+ reader.available -= i;
+ }
+ result = value;
+ }
+ return result;
+ }
+
+ private static int ReadByteOrThrow(Stream source)
+ {
+ int num = source.ReadByte();
+ bool flag = num < 0;
+ if (flag)
+ {
+ throw ProtoReader.EoF(null);
+ }
+ return num;
+ }
+
+ public static int ReadLengthPrefix(Stream source, bool expectHeader, PrefixStyle style, out int fieldNumber)
+ {
+ int num;
+ return ProtoReader.ReadLengthPrefix(source, expectHeader, style, out fieldNumber, out num);
+ }
+
+ public static int DirectReadLittleEndianInt32(Stream source)
+ {
+ return ProtoReader.ReadByteOrThrow(source) | ProtoReader.ReadByteOrThrow(source) << 8 | ProtoReader.ReadByteOrThrow(source) << 16 | ProtoReader.ReadByteOrThrow(source) << 24;
+ }
+
+ public static int DirectReadBigEndianInt32(Stream source)
+ {
+ return ProtoReader.ReadByteOrThrow(source) << 24 | ProtoReader.ReadByteOrThrow(source) << 16 | ProtoReader.ReadByteOrThrow(source) << 8 | ProtoReader.ReadByteOrThrow(source);
+ }
+
+ public static int DirectReadVarintInt32(Stream source)
+ {
+ uint result;
+ int num = ProtoReader.TryReadUInt32Variant(source, out result);
+ bool flag = num <= 0;
+ if (flag)
+ {
+ throw ProtoReader.EoF(null);
+ }
+ return (int)result;
+ }
+
+ public static void DirectReadBytes(Stream source, byte[] buffer, int offset, int count)
+ {
+ bool flag = source == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("source");
+ }
+ int num;
+ while (count > 0 && (num = source.Read(buffer, offset, count)) > 0)
+ {
+ count -= num;
+ offset += num;
+ }
+ bool flag2 = count > 0;
+ if (flag2)
+ {
+ throw ProtoReader.EoF(null);
+ }
+ }
+
+ public static byte[] DirectReadBytes(Stream source, int count)
+ {
+ byte[] array = new byte[count];
+ ProtoReader.DirectReadBytes(source, array, 0, count);
+ return array;
+ }
+
+ public static string DirectReadString(Stream source, int length)
+ {
+ byte[] array = new byte[length];
+ ProtoReader.DirectReadBytes(source, array, 0, length);
+ return Encoding.UTF8.GetString(array, 0, length);
+ }
+
+ public static int ReadLengthPrefix(Stream source, bool expectHeader, PrefixStyle style, out int fieldNumber, out int bytesRead)
+ {
+ fieldNumber = 0;
+ int result;
+ switch (style)
+ {
+ case PrefixStyle.None:
+ bytesRead = 0;
+ result = int.MaxValue;
+ break;
+ case PrefixStyle.Base128:
+ bytesRead = 0;
+ if (expectHeader)
+ {
+ uint num2;
+ int num = ProtoReader.TryReadUInt32Variant(source, out num2);
+ bytesRead += num;
+ bool flag = num > 0;
+ if (flag)
+ {
+ bool flag2 = (num2 & 7u) != 2u;
+ if (flag2)
+ {
+ throw new InvalidOperationException();
+ }
+ fieldNumber = (int)(num2 >> 3);
+ num = ProtoReader.TryReadUInt32Variant(source, out num2);
+ bytesRead += num;
+ bool flag3 = bytesRead == 0;
+ if (flag3)
+ {
+ throw ProtoReader.EoF(null);
+ }
+ result = (int)num2;
+ }
+ else
+ {
+ bytesRead = 0;
+ result = -1;
+ }
+ }
+ else
+ {
+ uint num2;
+ int num = ProtoReader.TryReadUInt32Variant(source, out num2);
+ bytesRead += num;
+ result = (int)((bytesRead < 0) ? uint.MaxValue : num2);
+ }
+ break;
+ case PrefixStyle.Fixed32:
+ {
+ int num3 = source.ReadByte();
+ bool flag4 = num3 < 0;
+ if (flag4)
+ {
+ bytesRead = 0;
+ result = -1;
+ }
+ else
+ {
+ bytesRead = 4;
+ result = (num3 | ProtoReader.ReadByteOrThrow(source) << 8 | ProtoReader.ReadByteOrThrow(source) << 16 | ProtoReader.ReadByteOrThrow(source) << 24);
+ }
+ break;
+ }
+ case PrefixStyle.Fixed32BigEndian:
+ {
+ int num4 = source.ReadByte();
+ bool flag5 = num4 < 0;
+ if (flag5)
+ {
+ bytesRead = 0;
+ result = -1;
+ }
+ else
+ {
+ bytesRead = 4;
+ result = (num4 << 24 | ProtoReader.ReadByteOrThrow(source) << 16 | ProtoReader.ReadByteOrThrow(source) << 8 | ProtoReader.ReadByteOrThrow(source));
+ }
+ break;
+ }
+ default:
+ throw new ArgumentOutOfRangeException("style");
+ }
+ return result;
+ }
+
+ private static int TryReadUInt32Variant(Stream source, out uint value)
+ {
+ value = 0u;
+ int num = source.ReadByte();
+ bool flag = num < 0;
+ int result;
+ if (flag)
+ {
+ result = 0;
+ }
+ else
+ {
+ value = (uint)num;
+ bool flag2 = (value & 128u) == 0u;
+ if (flag2)
+ {
+ result = 1;
+ }
+ else
+ {
+ value &= 127u;
+ num = source.ReadByte();
+ bool flag3 = num < 0;
+ if (flag3)
+ {
+ throw ProtoReader.EoF(null);
+ }
+ value |= (uint)((uint)(num & 127) << 7);
+ bool flag4 = (num & 128) == 0;
+ if (flag4)
+ {
+ result = 2;
+ }
+ else
+ {
+ num = source.ReadByte();
+ bool flag5 = num < 0;
+ if (flag5)
+ {
+ throw ProtoReader.EoF(null);
+ }
+ value |= (uint)((uint)(num & 127) << 14);
+ bool flag6 = (num & 128) == 0;
+ if (flag6)
+ {
+ result = 3;
+ }
+ else
+ {
+ num = source.ReadByte();
+ bool flag7 = num < 0;
+ if (flag7)
+ {
+ throw ProtoReader.EoF(null);
+ }
+ value |= (uint)((uint)(num & 127) << 21);
+ bool flag8 = (num & 128) == 0;
+ if (flag8)
+ {
+ result = 4;
+ }
+ else
+ {
+ num = source.ReadByte();
+ bool flag9 = num < 0;
+ if (flag9)
+ {
+ throw ProtoReader.EoF(null);
+ }
+ value |= (uint)((uint)num << 28);
+ bool flag10 = (num & 240) == 0;
+ if (!flag10)
+ {
+ throw new OverflowException();
+ }
+ result = 5;
+ }
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ internal static void Seek(Stream source, int count, byte[] buffer)
+ {
+ bool canSeek = source.CanSeek;
+ if (canSeek)
+ {
+ source.Seek((long)count, SeekOrigin.Current);
+ count = 0;
+ }
+ else
+ {
+ bool flag = buffer != null;
+ if (flag)
+ {
+ int num;
+ while (count > buffer.Length && (num = source.Read(buffer, 0, buffer.Length)) > 0)
+ {
+ count -= num;
+ }
+ while (count > 0 && (num = source.Read(buffer, 0, count)) > 0)
+ {
+ count -= num;
+ }
+ }
+ else
+ {
+ buffer = BufferPool.GetBuffer();
+ try
+ {
+ int num2;
+ while (count > buffer.Length && (num2 = source.Read(buffer, 0, buffer.Length)) > 0)
+ {
+ count -= num2;
+ }
+ while (count > 0 && (num2 = source.Read(buffer, 0, count)) > 0)
+ {
+ count -= num2;
+ }
+ }
+ finally
+ {
+ BufferPool.ReleaseBufferToPool(ref buffer);
+ }
+ }
+ }
+ bool flag2 = count > 0;
+ if (flag2)
+ {
+ throw ProtoReader.EoF(null);
+ }
+ }
+
+ internal static Exception AddErrorData(Exception exception, ProtoReader source)
+ {
+ bool flag = exception != null && source != null && !exception.Data.Contains("protoSource");
+ if (flag)
+ {
+ exception.Data.Add("protoSource", string.Format("tag={0}; wire-type={1}; offset={2}; depth={3}", new object[]
+ {
+ source.fieldNumber,
+ source.wireType,
+ source.position,
+ source.depth
+ }));
+ }
+ return exception;
+ }
+
+ private static Exception EoF(ProtoReader source)
+ {
+ return ProtoReader.AddErrorData(new EndOfStreamException(), source);
+ }
+
+ public void AppendExtensionData(IExtensible instance)
+ {
+ bool flag = instance == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("instance");
+ }
+ IExtension extensionObject = instance.GetExtensionObject(true);
+ bool commit = false;
+ Stream stream = extensionObject.BeginAppend();
+ try
+ {
+ using (ProtoWriter protoWriter = new ProtoWriter(stream, this.model, null))
+ {
+ this.AppendExtensionField(protoWriter);
+ protoWriter.Close();
+ }
+ commit = true;
+ }
+ finally
+ {
+ extensionObject.EndAppend(stream, commit);
+ }
+ }
+
+ private void AppendExtensionField(ProtoWriter writer)
+ {
+ ProtoWriter.WriteFieldHeader(this.fieldNumber, this.wireType, writer);
+ switch (this.wireType)
+ {
+ case WireType.Variant:
+ case WireType.Fixed64:
+ case WireType.SignedVariant:
+ ProtoWriter.WriteInt64(this.ReadInt64(), writer);
+ return;
+ case WireType.String:
+ ProtoWriter.WriteBytes(ProtoReader.AppendBytes(null, this), writer);
+ return;
+ case WireType.StartGroup:
+ {
+ SubItemToken token = ProtoReader.StartSubItem(this);
+ SubItemToken token2 = ProtoWriter.StartSubItem(null, writer);
+ while (this.ReadFieldHeader() > 0)
+ {
+ this.AppendExtensionField(writer);
+ }
+ ProtoReader.EndSubItem(token, this);
+ ProtoWriter.EndSubItem(token2, writer);
+ return;
+ }
+ case WireType.Fixed32:
+ ProtoWriter.WriteInt32(this.ReadInt32(), writer);
+ return;
+ }
+ throw this.CreateWireTypeException();
+ }
+
+ public static bool HasSubValue(WireType wireType, ProtoReader source)
+ {
+ bool flag = source == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("source");
+ }
+ bool flag2 = source.blockEnd <= source.position || wireType == WireType.EndGroup;
+ bool result;
+ if (flag2)
+ {
+ result = false;
+ }
+ else
+ {
+ source.wireType = wireType;
+ result = true;
+ }
+ return result;
+ }
+
+ internal int GetTypeKey(ref Type type)
+ {
+ return this.model.GetKey(ref type);
+ }
+
+ internal Type DeserializeType(string value)
+ {
+ return TypeModel.DeserializeType(this.model, value);
+ }
+
+ internal void SetRootObject(object value)
+ {
+ this.netCache.SetKeyedObject(0, value);
+ this.trapCount -= 1u;
+ }
+
+ public static void NoteObject(object value, ProtoReader reader)
+ {
+ bool flag = reader == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("reader");
+ }
+ bool flag2 = reader.trapCount > 0u;
+ if (flag2)
+ {
+ reader.netCache.RegisterTrappedObject(value);
+ reader.trapCount -= 1u;
+ }
+ }
+
+ public Type ReadType()
+ {
+ return TypeModel.DeserializeType(this.model, this.ReadString());
+ }
+
+ internal void TrapNextObject(int newObjectKey)
+ {
+ this.trapCount += 1u;
+ this.netCache.SetKeyedObject(newObjectKey, null);
+ }
+
+ internal void CheckFullyConsumed()
+ {
+ bool flag = this.isFixedLength;
+ if (flag)
+ {
+ bool flag2 = this.dataRemaining != 0;
+ if (flag2)
+ {
+ throw new ProtoException("Incorrect number of bytes consumed");
+ }
+ }
+ else
+ {
+ bool flag3 = this.available != 0;
+ if (flag3)
+ {
+ throw new ProtoException("Unconsumed data left in the buffer; this suggests corrupt input");
+ }
+ }
+ }
+
+ public static object Merge(ProtoReader parent, object from, object to)
+ {
+ bool flag = parent == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("parent");
+ }
+ TypeModel typeModel = parent.Model;
+ SerializationContext serializationContext = parent.Context;
+ bool flag2 = typeModel == null;
+ if (flag2)
+ {
+ throw new InvalidOperationException("Types cannot be merged unless a type-model has been specified");
+ }
+ object result;
+ using (MemoryStream memoryStream = new MemoryStream())
+ {
+ typeModel.Serialize(memoryStream, from, serializationContext);
+ memoryStream.Position = 0L;
+ result = typeModel.Deserialize(memoryStream, to, null);
+ }
+ return result;
+ }
+
+ internal static ProtoReader Create(Stream source, TypeModel model, SerializationContext context, int len)
+ {
+ ProtoReader recycled = ProtoReader.GetRecycled();
+ bool flag = recycled == null;
+ ProtoReader result;
+ if (flag)
+ {
+ result = new ProtoReader(source, model, context, len);
+ }
+ else
+ {
+ ProtoReader.Init(recycled, source, model, context, len);
+ result = recycled;
+ }
+ return result;
+ }
+
+ private static ProtoReader GetRecycled()
+ {
+ ProtoReader result = ProtoReader.lastReader;
+ ProtoReader.lastReader = null;
+ return result;
+ }
+
+ internal static void Recycle(ProtoReader reader)
+ {
+ bool flag = reader != null;
+ if (flag)
+ {
+ reader.Dispose();
+ ProtoReader.lastReader = reader;
+ }
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoReader.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoReader.cs.meta new file mode 100644 index 00000000..20a81efd --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoReader.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c2861b991d19ced42991a21212bf2e44 +timeCreated: 1611404494 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoTypeCode.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoTypeCode.cs new file mode 100644 index 00000000..80039345 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoTypeCode.cs @@ -0,0 +1,30 @@ +using System;
+
+namespace ProtoBuf
+{
+ internal enum ProtoTypeCode
+ {
+ Empty,
+ Unknown,
+ Boolean = 3,
+ Char,
+ SByte,
+ Byte,
+ Int16,
+ UInt16,
+ Int32,
+ UInt32,
+ Int64,
+ UInt64,
+ Single,
+ Double,
+ Decimal,
+ DateTime,
+ String = 18,
+ TimeSpan = 100,
+ ByteArray,
+ Guid,
+ Uri,
+ Type
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoTypeCode.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoTypeCode.cs.meta new file mode 100644 index 00000000..0c507e5c --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoTypeCode.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 40d0908bcdffe8f4781b540b382296b0 +timeCreated: 1611403615 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoWriter.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoWriter.cs new file mode 100644 index 00000000..470c8605 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoWriter.cs @@ -0,0 +1,1102 @@ +using System;
+using System.IO;
+using System.Text;
+using ProtoBuf.Meta;
+
+namespace ProtoBuf
+{
+ public sealed class ProtoWriter : IDisposable
+ {
+ internal NetObjectCache NetCache
+ {
+ get
+ {
+ return this.netCache;
+ }
+ }
+
+ internal WireType WireType
+ {
+ get
+ {
+ return this.wireType;
+ }
+ }
+
+ public SerializationContext Context
+ {
+ get
+ {
+ return this.context;
+ }
+ }
+
+ public TypeModel Model
+ {
+ get
+ {
+ return this.model;
+ }
+ }
+
+ private Stream dest;
+
+ private TypeModel model;
+
+ private readonly NetObjectCache netCache = new NetObjectCache();
+
+ private int fieldNumber;
+
+ private int flushLock;
+
+ private WireType wireType;
+
+ private int depth = 0;
+
+ private const int RecursionCheckDepth = 25;
+
+ private MutableList recursionStack;
+
+ private readonly SerializationContext context;
+
+ private byte[] ioBuffer;
+
+ private int ioIndex;
+
+ private int position;
+
+ private static readonly UTF8Encoding encoding = new UTF8Encoding();
+
+ private int packedFieldNumber;
+
+ public static void WriteObject(object value, int key, ProtoWriter writer)
+ {
+ bool flag = writer == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("writer");
+ }
+ bool flag2 = writer.model == null;
+ if (flag2)
+ {
+ throw new InvalidOperationException("Cannot serialize sub-objects unless a model is provided");
+ }
+ SubItemToken token = ProtoWriter.StartSubItem(value, writer);
+ bool flag3 = key >= 0;
+ if (flag3)
+ {
+ writer.model.Serialize(key, value, writer);
+ }
+ else
+ {
+ bool flag4 = writer.model != null && writer.model.TrySerializeAuxiliaryType(writer, value.GetType(), DataFormat.Default, 1, value, false);
+ if (!flag4)
+ {
+ TypeModel.ThrowUnexpectedType(value.GetType());
+ }
+ }
+ ProtoWriter.EndSubItem(token, writer);
+ }
+
+ public static void WriteRecursionSafeObject(object value, int key, ProtoWriter writer)
+ {
+ bool flag = writer == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("writer");
+ }
+ bool flag2 = writer.model == null;
+ if (flag2)
+ {
+ throw new InvalidOperationException("Cannot serialize sub-objects unless a model is provided");
+ }
+ SubItemToken token = ProtoWriter.StartSubItem(null, writer);
+ writer.model.Serialize(key, value, writer);
+ ProtoWriter.EndSubItem(token, writer);
+ }
+
+ internal static void WriteObject(object value, int key, ProtoWriter writer, PrefixStyle style, int fieldNumber)
+ {
+ bool flag = writer.model == null;
+ if (flag)
+ {
+ throw new InvalidOperationException("Cannot serialize sub-objects unless a model is provided");
+ }
+ bool flag2 = writer.wireType != WireType.None;
+ if (flag2)
+ {
+ throw ProtoWriter.CreateException(writer);
+ }
+ if (style != PrefixStyle.Base128)
+ {
+ if (style - PrefixStyle.Fixed32 > 1)
+ {
+ throw new ArgumentOutOfRangeException("style");
+ }
+ writer.fieldNumber = 0;
+ writer.wireType = WireType.Fixed32;
+ }
+ else
+ {
+ writer.wireType = WireType.String;
+ writer.fieldNumber = fieldNumber;
+ bool flag3 = fieldNumber > 0;
+ if (flag3)
+ {
+ ProtoWriter.WriteHeaderCore(fieldNumber, WireType.String, writer);
+ }
+ }
+ SubItemToken token = ProtoWriter.StartSubItem(value, writer, true);
+ bool flag4 = key < 0;
+ if (flag4)
+ {
+ bool flag5 = !writer.model.TrySerializeAuxiliaryType(writer, value.GetType(), DataFormat.Default, 1, value, false);
+ if (flag5)
+ {
+ TypeModel.ThrowUnexpectedType(value.GetType());
+ }
+ }
+ else
+ {
+ writer.model.Serialize(key, value, writer);
+ }
+ ProtoWriter.EndSubItem(token, writer, style);
+ }
+
+ internal int GetTypeKey(ref Type type)
+ {
+ return this.model.GetKey(ref type);
+ }
+
+ public static void WriteFieldHeader(int fieldNumber, WireType wireType, ProtoWriter writer)
+ {
+ bool flag = writer == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("writer");
+ }
+ bool flag2 = writer.wireType != WireType.None;
+ if (flag2)
+ {
+ throw new InvalidOperationException(string.Concat(new string[]
+ {
+ "Cannot write a ",
+ wireType.ToString(),
+ " header until the ",
+ writer.wireType.ToString(),
+ " data has been written"
+ }));
+ }
+ bool flag3 = fieldNumber < 0;
+ if (flag3)
+ {
+ throw new ArgumentOutOfRangeException("fieldNumber");
+ }
+ switch (wireType)
+ {
+ case WireType.Variant:
+ case WireType.Fixed64:
+ case WireType.String:
+ case WireType.StartGroup:
+ case WireType.Fixed32:
+ case WireType.SignedVariant:
+ {
+ bool flag4 = writer.packedFieldNumber == 0;
+ if (flag4)
+ {
+ writer.fieldNumber = fieldNumber;
+ writer.wireType = wireType;
+ ProtoWriter.WriteHeaderCore(fieldNumber, wireType, writer);
+ }
+ else
+ {
+ bool flag5 = writer.packedFieldNumber == fieldNumber;
+ if (!flag5)
+ {
+ throw new InvalidOperationException("Field mismatch during packed encoding; expected " + writer.packedFieldNumber.ToString() + " but received " + fieldNumber.ToString());
+ }
+ WireType wireType2 = wireType;
+ if (wireType2 > WireType.Fixed64 && wireType2 != WireType.Fixed32 && wireType2 != WireType.SignedVariant)
+ {
+ throw new InvalidOperationException("Wire-type cannot be encoded as packed: " + wireType.ToString());
+ }
+ writer.fieldNumber = fieldNumber;
+ writer.wireType = wireType;
+ }
+ return;
+ }
+ }
+ throw new ArgumentException("Invalid wire-type: " + wireType.ToString(), "wireType");
+ }
+
+ internal static void WriteHeaderCore(int fieldNumber, WireType wireType, ProtoWriter writer)
+ {
+ uint value = (uint)(fieldNumber << 3 | (int)(wireType & (WireType)7));
+ ProtoWriter.WriteUInt32Variant(value, writer);
+ }
+
+ public static void WriteBytes(byte[] data, ProtoWriter writer)
+ {
+ bool flag = data == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("data");
+ }
+ ProtoWriter.WriteBytes(data, 0, data.Length, writer);
+ }
+
+ public static void WriteBytes(byte[] data, int offset, int length, ProtoWriter writer)
+ {
+ bool flag = data == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("data");
+ }
+ bool flag2 = writer == null;
+ if (flag2)
+ {
+ throw new ArgumentNullException("writer");
+ }
+ switch (writer.wireType)
+ {
+ case WireType.Fixed64:
+ {
+ bool flag3 = length != 8;
+ if (flag3)
+ {
+ throw new ArgumentException("length");
+ }
+ goto IL_EE;
+ }
+ case WireType.String:
+ {
+ ProtoWriter.WriteUInt32Variant((uint)length, writer);
+ writer.wireType = WireType.None;
+ bool flag4 = length == 0;
+ if (flag4)
+ {
+ return;
+ }
+ bool flag5 = writer.flushLock != 0 || length <= writer.ioBuffer.Length;
+ if (flag5)
+ {
+ goto IL_EE;
+ }
+ ProtoWriter.Flush(writer);
+ writer.dest.Write(data, offset, length);
+ writer.position += length;
+ return;
+ }
+ case WireType.Fixed32:
+ {
+ bool flag6 = length != 4;
+ if (flag6)
+ {
+ throw new ArgumentException("length");
+ }
+ goto IL_EE;
+ }
+ }
+ throw ProtoWriter.CreateException(writer);
+ IL_EE:
+ ProtoWriter.DemandSpace(length, writer);
+ Helpers.BlockCopy(data, offset, writer.ioBuffer, writer.ioIndex, length);
+ ProtoWriter.IncrementedAndReset(length, writer);
+ }
+
+ private static void CopyRawFromStream(Stream source, ProtoWriter writer)
+ {
+ byte[] array = writer.ioBuffer;
+ int num = array.Length - writer.ioIndex;
+ int num2 = 1;
+ while (num > 0 && (num2 = source.Read(array, writer.ioIndex, num)) > 0)
+ {
+ writer.ioIndex += num2;
+ writer.position += num2;
+ num -= num2;
+ }
+ bool flag = num2 <= 0;
+ if (!flag)
+ {
+ bool flag2 = writer.flushLock == 0;
+ if (flag2)
+ {
+ ProtoWriter.Flush(writer);
+ while ((num2 = source.Read(array, 0, array.Length)) > 0)
+ {
+ writer.dest.Write(array, 0, num2);
+ writer.position += num2;
+ }
+ }
+ else
+ {
+ for (;;)
+ {
+ ProtoWriter.DemandSpace(128, writer);
+ bool flag3 = (num2 = source.Read(writer.ioBuffer, writer.ioIndex, writer.ioBuffer.Length - writer.ioIndex)) <= 0;
+ if (flag3)
+ {
+ break;
+ }
+ writer.position += num2;
+ writer.ioIndex += num2;
+ }
+ }
+ }
+ }
+
+ private static void IncrementedAndReset(int length, ProtoWriter writer)
+ {
+ Helpers.DebugAssert(length >= 0);
+ writer.ioIndex += length;
+ writer.position += length;
+ writer.wireType = WireType.None;
+ }
+
+ public static SubItemToken StartSubItem(object instance, ProtoWriter writer)
+ {
+ return ProtoWriter.StartSubItem(instance, writer, false);
+ }
+
+ private void CheckRecursionStackAndPush(object instance)
+ {
+ bool flag = this.recursionStack == null;
+ if (flag)
+ {
+ this.recursionStack = new MutableList();
+ }
+ else
+ {
+ int num = 0;
+ bool flag2 = instance != null && (num = this.recursionStack.IndexOfReference(instance)) >= 0;
+ if (flag2)
+ {
+ Helpers.DebugWriteLine("Stack:");
+ foreach (object obj in this.recursionStack)
+ {
+ Helpers.DebugWriteLine((obj == null) ? "<null>" : obj.ToString());
+ }
+ Helpers.DebugWriteLine((instance == null) ? "<null>" : instance.ToString());
+ throw new ProtoException("Possible recursion detected (offset: " + (this.recursionStack.Count - num).ToString() + " level(s)): " + instance.ToString());
+ }
+ }
+ this.recursionStack.Add(instance);
+ }
+
+ private void PopRecursionStack()
+ {
+ this.recursionStack.RemoveLast();
+ }
+
+ private static SubItemToken StartSubItem(object instance, ProtoWriter writer, bool allowFixed)
+ {
+ bool flag = writer == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("writer");
+ }
+ int num = writer.depth + 1;
+ writer.depth = num;
+ bool flag2 = num > 25;
+ if (flag2)
+ {
+ writer.CheckRecursionStackAndPush(instance);
+ }
+ bool flag3 = writer.packedFieldNumber != 0;
+ if (flag3)
+ {
+ throw new InvalidOperationException("Cannot begin a sub-item while performing packed encoding");
+ }
+ switch (writer.wireType)
+ {
+ case WireType.String:
+ {
+ bool flag4 = writer.model != null && writer.model.ForwardsOnly;
+ if (flag4)
+ {
+ throw new ProtoException("Should not be buffering data");
+ }
+ writer.wireType = WireType.None;
+ ProtoWriter.DemandSpace(32, writer);
+ writer.flushLock++;
+ writer.position++;
+ num = writer.ioIndex;
+ writer.ioIndex = num + 1;
+ return new SubItemToken(num);
+ }
+ case WireType.StartGroup:
+ writer.wireType = WireType.None;
+ return new SubItemToken(-writer.fieldNumber);
+ case WireType.Fixed32:
+ {
+ bool flag5 = !allowFixed;
+ if (flag5)
+ {
+ throw ProtoWriter.CreateException(writer);
+ }
+ ProtoWriter.DemandSpace(32, writer);
+ writer.flushLock++;
+ SubItemToken result = new SubItemToken(writer.ioIndex);
+ ProtoWriter.IncrementedAndReset(4, writer);
+ return result;
+ }
+ }
+ throw ProtoWriter.CreateException(writer);
+ }
+
+ public static void EndSubItem(SubItemToken token, ProtoWriter writer)
+ {
+ ProtoWriter.EndSubItem(token, writer, PrefixStyle.Base128);
+ }
+
+ private static void EndSubItem(SubItemToken token, ProtoWriter writer, PrefixStyle style)
+ {
+ bool flag = writer == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("writer");
+ }
+ bool flag2 = writer.wireType != WireType.None;
+ if (flag2)
+ {
+ throw ProtoWriter.CreateException(writer);
+ }
+ int value = token.value;
+ bool flag3 = writer.depth <= 0;
+ if (flag3)
+ {
+ throw ProtoWriter.CreateException(writer);
+ }
+ int num = writer.depth;
+ writer.depth = num - 1;
+ bool flag4 = num > 25;
+ if (flag4)
+ {
+ writer.PopRecursionStack();
+ }
+ writer.packedFieldNumber = 0;
+ bool flag5 = value < 0;
+ if (flag5)
+ {
+ ProtoWriter.WriteHeaderCore(-value, WireType.EndGroup, writer);
+ writer.wireType = WireType.None;
+ }
+ else
+ {
+ switch (style)
+ {
+ case PrefixStyle.Base128:
+ {
+ int num2 = writer.ioIndex - value - 1;
+ int num3 = 0;
+ uint num4 = (uint)num2;
+ while ((num4 >>= 7) > 0u)
+ {
+ num3++;
+ }
+ bool flag6 = num3 == 0;
+ if (flag6)
+ {
+ writer.ioBuffer[value] = (byte)(num2 & 127);
+ }
+ else
+ {
+ ProtoWriter.DemandSpace(num3, writer);
+ byte[] array = writer.ioBuffer;
+ Helpers.BlockCopy(array, value + 1, array, value + 1 + num3, num2);
+ num4 = (uint)num2;
+ do
+ {
+ array[value++] = (byte)((num4 & 127u) | 128u);
+ }
+ while ((num4 >>= 7) > 0u);
+ array[value - 1] = (byte)((int)array[value - 1] & -129);
+ writer.position += num3;
+ writer.ioIndex += num3;
+ }
+ break;
+ }
+ case PrefixStyle.Fixed32:
+ {
+ int num2 = writer.ioIndex - value - 4;
+ ProtoWriter.WriteInt32ToBuffer(num2, writer.ioBuffer, value);
+ break;
+ }
+ case PrefixStyle.Fixed32BigEndian:
+ {
+ int num2 = writer.ioIndex - value - 4;
+ byte[] array2 = writer.ioBuffer;
+ ProtoWriter.WriteInt32ToBuffer(num2, array2, value);
+ byte b = array2[value];
+ array2[value] = array2[value + 3];
+ array2[value + 3] = b;
+ b = array2[value + 1];
+ array2[value + 1] = array2[value + 2];
+ array2[value + 2] = b;
+ break;
+ }
+ default:
+ throw new ArgumentOutOfRangeException("style");
+ }
+ num = writer.flushLock - 1;
+ writer.flushLock = num;
+ bool flag7 = num == 0 && writer.ioIndex >= 1024;
+ if (flag7)
+ {
+ ProtoWriter.Flush(writer);
+ }
+ }
+ }
+
+ public ProtoWriter(Stream dest, TypeModel model, SerializationContext context)
+ {
+ bool flag = dest == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("dest");
+ }
+ bool flag2 = !dest.CanWrite;
+ if (flag2)
+ {
+ throw new ArgumentException("Cannot write to stream", "dest");
+ }
+ this.dest = dest;
+ this.ioBuffer = BufferPool.GetBuffer();
+ this.model = model;
+ this.wireType = WireType.None;
+ bool flag3 = context == null;
+ if (flag3)
+ {
+ context = SerializationContext.Default;
+ }
+ else
+ {
+ context.Freeze();
+ }
+ this.context = context;
+ }
+
+ void IDisposable.Dispose()
+ {
+ this.Dispose();
+ }
+
+ private void Dispose()
+ {
+ bool flag = this.dest != null;
+ if (flag)
+ {
+ ProtoWriter.Flush(this);
+ this.dest = null;
+ }
+ this.model = null;
+ BufferPool.ReleaseBufferToPool(ref this.ioBuffer);
+ }
+
+ internal static int GetPosition(ProtoWriter writer)
+ {
+ return writer.position;
+ }
+
+ private static void DemandSpace(int required, ProtoWriter writer)
+ {
+ bool flag = writer.ioBuffer.Length - writer.ioIndex < required;
+ if (flag)
+ {
+ bool flag2 = writer.flushLock == 0;
+ if (flag2)
+ {
+ ProtoWriter.Flush(writer);
+ bool flag3 = writer.ioBuffer.Length - writer.ioIndex >= required;
+ if (flag3)
+ {
+ return;
+ }
+ }
+ BufferPool.ResizeAndFlushLeft(ref writer.ioBuffer, required + writer.ioIndex, 0, writer.ioIndex);
+ }
+ }
+
+ public void Close()
+ {
+ bool flag = this.depth != 0 || this.flushLock != 0;
+ if (flag)
+ {
+ throw new InvalidOperationException("Unable to close stream in an incomplete state");
+ }
+ this.Dispose();
+ }
+
+ internal void CheckDepthFlushlock()
+ {
+ bool flag = this.depth != 0 || this.flushLock != 0;
+ if (flag)
+ {
+ throw new InvalidOperationException("The writer is in an incomplete state");
+ }
+ }
+
+ internal static void Flush(ProtoWriter writer)
+ {
+ bool flag = writer.flushLock == 0 && writer.ioIndex != 0;
+ if (flag)
+ {
+ writer.dest.Write(writer.ioBuffer, 0, writer.ioIndex);
+ writer.ioIndex = 0;
+ }
+ }
+
+ private static void WriteUInt32Variant(uint value, ProtoWriter writer)
+ {
+ ProtoWriter.DemandSpace(5, writer);
+ int num = 0;
+ do
+ {
+ byte[] array = writer.ioBuffer;
+ int num2 = writer.ioIndex;
+ writer.ioIndex = num2 + 1;
+ array[num2] = (byte)((value & 127u) | 128u);
+ num++;
+ }
+ while ((value >>= 7) > 0u);
+ byte[] array2 = writer.ioBuffer;
+ int num3 = writer.ioIndex - 1;
+ array2[num3] &= 127;
+ writer.position += num;
+ }
+
+ internal static uint Zig(int value)
+ {
+ return (uint)(value << 1 ^ value >> 31);
+ }
+
+ internal static ulong Zig(long value)
+ {
+ return (ulong)(value << 1 ^ value >> 63);
+ }
+
+ private static void WriteUInt64Variant(ulong value, ProtoWriter writer)
+ {
+ ProtoWriter.DemandSpace(10, writer);
+ int num = 0;
+ do
+ {
+ byte[] array = writer.ioBuffer;
+ int num2 = writer.ioIndex;
+ writer.ioIndex = num2 + 1;
+ array[num2] = (byte)((value & 127UL) | 128UL);
+ num++;
+ }
+ while ((value >>= 7) > 0UL);
+ byte[] array2 = writer.ioBuffer;
+ int num3 = writer.ioIndex - 1;
+ array2[num3] &= 127;
+ writer.position += num;
+ }
+
+ public static void WriteString(string value, ProtoWriter writer)
+ {
+ bool flag = writer == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("writer");
+ }
+ bool flag2 = writer.wireType != WireType.String;
+ if (flag2)
+ {
+ throw ProtoWriter.CreateException(writer);
+ }
+ bool flag3 = value == null;
+ if (flag3)
+ {
+ throw new ArgumentNullException("value");
+ }
+ int length = value.Length;
+ bool flag4 = length == 0;
+ if (flag4)
+ {
+ ProtoWriter.WriteUInt32Variant(0u, writer);
+ writer.wireType = WireType.None;
+ }
+ else
+ {
+ int byteCount = ProtoWriter.encoding.GetByteCount(value);
+ ProtoWriter.WriteUInt32Variant((uint)byteCount, writer);
+ ProtoWriter.DemandSpace(byteCount, writer);
+ int bytes = ProtoWriter.encoding.GetBytes(value, 0, value.Length, writer.ioBuffer, writer.ioIndex);
+ Helpers.DebugAssert(byteCount == bytes);
+ ProtoWriter.IncrementedAndReset(bytes, writer);
+ }
+ }
+
+ public static void WriteUInt64(ulong value, ProtoWriter writer)
+ {
+ bool flag = writer == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("writer");
+ }
+ WireType wireType = writer.wireType;
+ if (wireType != WireType.Variant)
+ {
+ if (wireType != WireType.Fixed64)
+ {
+ if (wireType != WireType.Fixed32)
+ {
+ throw ProtoWriter.CreateException(writer);
+ }
+ ProtoWriter.WriteUInt32(checked((uint)value), writer);
+ }
+ else
+ {
+ ProtoWriter.WriteInt64((long)value, writer);
+ }
+ }
+ else
+ {
+ ProtoWriter.WriteUInt64Variant(value, writer);
+ writer.wireType = WireType.None;
+ }
+ }
+
+ public static void WriteInt64(long value, ProtoWriter writer)
+ {
+ bool flag = writer == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("writer");
+ }
+ WireType wireType = writer.wireType;
+ if (wireType <= WireType.Fixed64)
+ {
+ if (wireType == WireType.Variant)
+ {
+ bool flag2 = value >= 0L;
+ if (flag2)
+ {
+ ProtoWriter.WriteUInt64Variant((ulong)value, writer);
+ writer.wireType = WireType.None;
+ }
+ else
+ {
+ ProtoWriter.DemandSpace(10, writer);
+ byte[] array = writer.ioBuffer;
+ int num = writer.ioIndex;
+ array[num] = (byte)(value | 128L);
+ array[num + 1] = (byte)((int)(value >> 7) | 128);
+ array[num + 2] = (byte)((int)(value >> 14) | 128);
+ array[num + 3] = (byte)((int)(value >> 21) | 128);
+ array[num + 4] = (byte)((int)(value >> 28) | 128);
+ array[num + 5] = (byte)((int)(value >> 35) | 128);
+ array[num + 6] = (byte)((int)(value >> 42) | 128);
+ array[num + 7] = (byte)((int)(value >> 49) | 128);
+ array[num + 8] = (byte)((int)(value >> 56) | 128);
+ array[num + 9] = 1;
+ ProtoWriter.IncrementedAndReset(10, writer);
+ }
+ return;
+ }
+ if (wireType == WireType.Fixed64)
+ {
+ ProtoWriter.DemandSpace(8, writer);
+ byte[] array = writer.ioBuffer;
+ int num = writer.ioIndex;
+ array[num] = (byte)value;
+ array[num + 1] = (byte)(value >> 8);
+ array[num + 2] = (byte)(value >> 16);
+ array[num + 3] = (byte)(value >> 24);
+ array[num + 4] = (byte)(value >> 32);
+ array[num + 5] = (byte)(value >> 40);
+ array[num + 6] = (byte)(value >> 48);
+ array[num + 7] = (byte)(value >> 56);
+ ProtoWriter.IncrementedAndReset(8, writer);
+ return;
+ }
+ }
+ else
+ {
+ if (wireType == WireType.Fixed32)
+ {
+ ProtoWriter.WriteInt32(checked((int)value), writer);
+ return;
+ }
+ if (wireType == WireType.SignedVariant)
+ {
+ ProtoWriter.WriteUInt64Variant(ProtoWriter.Zig(value), writer);
+ writer.wireType = WireType.None;
+ return;
+ }
+ }
+ throw ProtoWriter.CreateException(writer);
+ }
+
+ public static void WriteUInt32(uint value, ProtoWriter writer)
+ {
+ bool flag = writer == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("writer");
+ }
+ WireType wireType = writer.wireType;
+ if (wireType != WireType.Variant)
+ {
+ if (wireType != WireType.Fixed64)
+ {
+ if (wireType != WireType.Fixed32)
+ {
+ throw ProtoWriter.CreateException(writer);
+ }
+ ProtoWriter.WriteInt32((int)value, writer);
+ }
+ else
+ {
+ ProtoWriter.WriteInt64((long)value, writer);
+ }
+ }
+ else
+ {
+ ProtoWriter.WriteUInt32Variant(value, writer);
+ writer.wireType = WireType.None;
+ }
+ }
+
+ public static void WriteInt16(short value, ProtoWriter writer)
+ {
+ ProtoWriter.WriteInt32((int)value, writer);
+ }
+
+ public static void WriteUInt16(ushort value, ProtoWriter writer)
+ {
+ ProtoWriter.WriteUInt32((uint)value, writer);
+ }
+
+ public static void WriteByte(byte value, ProtoWriter writer)
+ {
+ ProtoWriter.WriteUInt32((uint)value, writer);
+ }
+
+ public static void WriteSByte(sbyte value, ProtoWriter writer)
+ {
+ ProtoWriter.WriteInt32((int)value, writer);
+ }
+
+ private static void WriteInt32ToBuffer(int value, byte[] buffer, int index)
+ {
+ buffer[index] = (byte)value;
+ buffer[index + 1] = (byte)(value >> 8);
+ buffer[index + 2] = (byte)(value >> 16);
+ buffer[index + 3] = (byte)(value >> 24);
+ }
+
+ public static void WriteInt32(int value, ProtoWriter writer)
+ {
+ bool flag = writer == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("writer");
+ }
+ WireType wireType = writer.wireType;
+ if (wireType <= WireType.Fixed64)
+ {
+ if (wireType == WireType.Variant)
+ {
+ bool flag2 = value >= 0;
+ if (flag2)
+ {
+ ProtoWriter.WriteUInt32Variant((uint)value, writer);
+ writer.wireType = WireType.None;
+ }
+ else
+ {
+ ProtoWriter.DemandSpace(10, writer);
+ byte[] array = writer.ioBuffer;
+ int num = writer.ioIndex;
+ array[num] = (byte)(value | 128);
+ array[num + 1] = (byte)(value >> 7 | 128);
+ array[num + 2] = (byte)(value >> 14 | 128);
+ array[num + 3] = (byte)(value >> 21 | 128);
+ array[num + 4] = (byte)(value >> 28 | 128);
+ array[num + 5] = (array[num + 6] = (array[num + 7] = (array[num + 8] = byte.MaxValue)));
+ array[num + 9] = 1;
+ ProtoWriter.IncrementedAndReset(10, writer);
+ }
+ return;
+ }
+ if (wireType == WireType.Fixed64)
+ {
+ ProtoWriter.DemandSpace(8, writer);
+ byte[] array = writer.ioBuffer;
+ int num = writer.ioIndex;
+ array[num] = (byte)value;
+ array[num + 1] = (byte)(value >> 8);
+ array[num + 2] = (byte)(value >> 16);
+ array[num + 3] = (byte)(value >> 24);
+ array[num + 4] = (array[num + 5] = (array[num + 6] = (array[num + 7] = 0)));
+ ProtoWriter.IncrementedAndReset(8, writer);
+ return;
+ }
+ }
+ else
+ {
+ if (wireType == WireType.Fixed32)
+ {
+ ProtoWriter.DemandSpace(4, writer);
+ ProtoWriter.WriteInt32ToBuffer(value, writer.ioBuffer, writer.ioIndex);
+ ProtoWriter.IncrementedAndReset(4, writer);
+ return;
+ }
+ if (wireType == WireType.SignedVariant)
+ {
+ ProtoWriter.WriteUInt32Variant(ProtoWriter.Zig(value), writer);
+ writer.wireType = WireType.None;
+ return;
+ }
+ }
+ throw ProtoWriter.CreateException(writer);
+ }
+
+ public unsafe static void WriteDouble(double value, ProtoWriter writer)
+ {
+ bool flag = writer == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("writer");
+ }
+ WireType wireType = writer.wireType;
+ if (wireType != WireType.Fixed64)
+ {
+ if (wireType != WireType.Fixed32)
+ {
+ throw ProtoWriter.CreateException(writer);
+ }
+ float value2 = (float)value;
+ bool flag2 = Helpers.IsInfinity(value2) && !Helpers.IsInfinity(value);
+ if (flag2)
+ {
+ throw new OverflowException();
+ }
+ ProtoWriter.WriteSingle(value2, writer);
+ }
+ else
+ {
+ ProtoWriter.WriteInt64(*(long*)(&value), writer);
+ }
+ }
+
+ public unsafe static void WriteSingle(float value, ProtoWriter writer)
+ {
+ bool flag = writer == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("writer");
+ }
+ WireType wireType = writer.wireType;
+ if (wireType != WireType.Fixed64)
+ {
+ if (wireType != WireType.Fixed32)
+ {
+ throw ProtoWriter.CreateException(writer);
+ }
+ ProtoWriter.WriteInt32(*(int*)(&value), writer);
+ }
+ else
+ {
+ ProtoWriter.WriteDouble((double)value, writer);
+ }
+ }
+
+ public static void ThrowEnumException(ProtoWriter writer, object enumValue)
+ {
+ bool flag = writer == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("writer");
+ }
+ string str = (enumValue == null) ? "<null>" : (enumValue.GetType().FullName + "." + enumValue.ToString());
+ throw new ProtoException("No wire-value is mapped to the enum " + str + " at position " + writer.position.ToString());
+ }
+
+ internal static Exception CreateException(ProtoWriter writer)
+ {
+ bool flag = writer == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("writer");
+ }
+ return new ProtoException("Invalid serialization operation with wire-type " + writer.wireType.ToString() + " at position " + writer.position.ToString());
+ }
+
+ public static void WriteBoolean(bool value, ProtoWriter writer)
+ {
+ ProtoWriter.WriteUInt32(value ? 1u : 0u, writer);
+ }
+
+ public static void AppendExtensionData(IExtensible instance, ProtoWriter writer)
+ {
+ bool flag = instance == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("instance");
+ }
+ bool flag2 = writer == null;
+ if (flag2)
+ {
+ throw new ArgumentNullException("writer");
+ }
+ bool flag3 = writer.wireType != WireType.None;
+ if (flag3)
+ {
+ throw ProtoWriter.CreateException(writer);
+ }
+ IExtension extensionObject = instance.GetExtensionObject(false);
+ bool flag4 = extensionObject != null;
+ if (flag4)
+ {
+ Stream stream = extensionObject.BeginQuery();
+ try
+ {
+ ProtoWriter.CopyRawFromStream(stream, writer);
+ }
+ finally
+ {
+ extensionObject.EndQuery(stream);
+ }
+ }
+ }
+
+ public static void SetPackedField(int fieldNumber, ProtoWriter writer)
+ {
+ bool flag = fieldNumber <= 0;
+ if (flag)
+ {
+ throw new ArgumentOutOfRangeException("fieldNumber");
+ }
+ bool flag2 = writer == null;
+ if (flag2)
+ {
+ throw new ArgumentNullException("writer");
+ }
+ writer.packedFieldNumber = fieldNumber;
+ }
+
+ internal string SerializeType(Type type)
+ {
+ return TypeModel.SerializeType(this.model, type);
+ }
+
+ public void SetRootObject(object value)
+ {
+ this.NetCache.SetKeyedObject(0, value);
+ }
+
+ public static void WriteType(Type value, ProtoWriter writer)
+ {
+ bool flag = writer == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("writer");
+ }
+ ProtoWriter.WriteString(writer.SerializeType(value), writer);
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoWriter.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoWriter.cs.meta new file mode 100644 index 00000000..d48ab681 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoWriter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8cebcb43dfaf89a44a4f76b395b89452 +timeCreated: 1611404102 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/SerializationContext.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/SerializationContext.cs new file mode 100644 index 00000000..1259b708 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/SerializationContext.cs @@ -0,0 +1,57 @@ +using System;
+
+namespace ProtoBuf
+{
+ public sealed class SerializationContext
+ {
+ public object Context
+ {
+ get
+ {
+ return this.context;
+ }
+ set
+ {
+ bool flag = this.context != value;
+ if (flag)
+ {
+ this.ThrowIfFrozen();
+ this.context = value;
+ }
+ }
+ }
+
+ internal static SerializationContext Default
+ {
+ get
+ {
+ return SerializationContext.@default;
+ }
+ }
+
+ private bool frozen;
+
+ private object context;
+
+ private static readonly SerializationContext @default = new SerializationContext();
+
+ internal void Freeze()
+ {
+ this.frozen = true;
+ }
+
+ private void ThrowIfFrozen()
+ {
+ bool flag = this.frozen;
+ if (flag)
+ {
+ throw new InvalidOperationException("The serialization-context cannot be changed once it is in use");
+ }
+ }
+
+ static SerializationContext()
+ {
+ SerializationContext.@default.Freeze();
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/SerializationContext.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/SerializationContext.cs.meta new file mode 100644 index 00000000..bee2c1d5 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/SerializationContext.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 319befc067bfd6442bc8aaae3dd8e140 +timeCreated: 1611403546 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializer.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializer.cs new file mode 100644 index 00000000..c80cdea0 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializer.cs @@ -0,0 +1,268 @@ +using System;
+using System.Collections.Generic;
+using System.IO;
+using ProtoBuf.Meta;
+
+namespace ProtoBuf
+{
+ public static class Serializer
+ {
+ private static bool useMultiThread = false;
+
+ public static bool isSkipProtoIgnore = false;
+
+ private const string ProtoBinaryField = "proto";
+
+ public const int ListItemTag = 1;
+
+ public static class NonGeneric
+ {
+ public static object DeepClone(object instance)
+ {
+ return (instance == null) ? null : RuntimeTypeModel.Default.DeepClone(instance);
+ }
+
+ public static void Serialize(Stream dest, object instance)
+ {
+ bool flag = instance != null;
+ if (flag)
+ {
+ RuntimeTypeModel.Default.Serialize(dest, instance);
+ }
+ }
+
+ public static object Deserialize(Type type, Stream source)
+ {
+ return RuntimeTypeModel.Default.Deserialize(source, null, type);
+ }
+
+ public static object Merge(Stream source, object instance)
+ {
+ bool flag = instance == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("instance");
+ }
+ return RuntimeTypeModel.Default.Deserialize(source, instance, instance.GetType(), null);
+ }
+
+ public static void SerializeWithLengthPrefix(Stream destination, object instance, PrefixStyle style, int fieldNumber)
+ {
+ bool flag = instance == null;
+ if (flag)
+ {
+ throw new ArgumentNullException("instance");
+ }
+ RuntimeTypeModel @default = RuntimeTypeModel.Default;
+ @default.SerializeWithLengthPrefix(destination, instance, @default.MapType(instance.GetType()), style, fieldNumber);
+ }
+
+ public static bool TryDeserializeWithLengthPrefix(Stream source, PrefixStyle style, Serializer.TypeResolver resolver, out object value)
+ {
+ value = RuntimeTypeModel.Default.DeserializeWithLengthPrefix(source, null, null, style, 0, resolver);
+ return value != null;
+ }
+
+ public static bool CanSerialize(Type type)
+ {
+ return RuntimeTypeModel.Default.IsDefined(type);
+ }
+ }
+
+ public static class GlobalOptions
+ {
+ [Obsolete("Please use RuntimeTypeModel.Default.InferTagFromNameDefault instead (or on a per-model basis)", false)]
+ public static bool InferTagFromName
+ {
+ get
+ {
+ return RuntimeTypeModel.Default.InferTagFromNameDefault;
+ }
+ set
+ {
+ RuntimeTypeModel.Default.InferTagFromNameDefault = value;
+ }
+ }
+ }
+
+ public delegate Type TypeResolver(int fieldNumber);
+
+ public static string GetProto<T>()
+ {
+ return RuntimeTypeModel.Default.GetSchema(RuntimeTypeModel.Default.MapType(typeof(T)));
+ }
+
+ public static void SetMultiThread(bool multiThread)
+ {
+ Serializer.useMultiThread = multiThread;
+ }
+
+ public static void SetSkipProtoIgnore(bool skipProtoIgnore)
+ {
+ Serializer.isSkipProtoIgnore = skipProtoIgnore;
+ }
+
+ public static T DeepClone<T>(T instance)
+ {
+ bool flag = instance == null;
+ T result;
+ if (flag)
+ {
+ result = instance;
+ }
+ else
+ {
+ bool flag2 = Serializer.useMultiThread;
+ if (flag2)
+ {
+ RuntimeTypeModel @default = RuntimeTypeModel.Default;
+ RuntimeTypeModel obj = @default;
+ lock (obj)
+ {
+ return (T)((object)@default.DeepClone(instance));
+ }
+ }
+ result = (T)((object)RuntimeTypeModel.Default.DeepClone(instance));
+ }
+ return result;
+ }
+
+ public static T Merge<T>(Stream source, T instance)
+ {
+ bool flag = Serializer.useMultiThread;
+ if (flag)
+ {
+ RuntimeTypeModel @default = RuntimeTypeModel.Default;
+ RuntimeTypeModel obj = @default;
+ lock (obj)
+ {
+ return (T)((object)@default.Deserialize(source, instance, typeof(T)));
+ }
+ }
+ return (T)((object)RuntimeTypeModel.Default.Deserialize(source, instance, typeof(T)));
+ }
+
+ public static T Deserialize<T>(Stream source)
+ {
+ bool flag = Serializer.useMultiThread;
+ if (flag)
+ {
+ RuntimeTypeModel @default = RuntimeTypeModel.Default;
+ RuntimeTypeModel obj = @default;
+ lock (obj)
+ {
+ return (T)((object)@default.Deserialize(source, null, typeof(T)));
+ }
+ }
+ return (T)((object)RuntimeTypeModel.Default.Deserialize(source, null, typeof(T)));
+ }
+
+ public static void Serialize<T>(Stream destination, T instance)
+ {
+ bool flag = instance != null;
+ if (flag)
+ {
+ bool flag2 = Serializer.useMultiThread;
+ if (flag2)
+ {
+ RuntimeTypeModel @default = RuntimeTypeModel.Default;
+ RuntimeTypeModel obj = @default;
+ lock (obj)
+ {
+ @default.Serialize(destination, instance);
+ }
+ }
+ else
+ {
+ RuntimeTypeModel.Default.Serialize(destination, instance);
+ }
+ }
+ }
+
+ public static void Clear()
+ {
+ bool flag = Serializer.useMultiThread;
+ if (flag)
+ {
+ RuntimeTypeModel @default = RuntimeTypeModel.Default;
+ RuntimeTypeModel obj = @default;
+ lock (obj)
+ {
+ RuntimeTypeModel.Default.Clear();
+ }
+ }
+ }
+
+ public static TTo ChangeType<TFrom, TTo>(TFrom instance)
+ {
+ TTo result;
+ using (MemoryStream memoryStream = new MemoryStream())
+ {
+ Serializer.Serialize<TFrom>(memoryStream, instance);
+ memoryStream.Position = 0L;
+ result = Serializer.Deserialize<TTo>(memoryStream);
+ }
+ return result;
+ }
+
+ public static void PrepareSerializer<T>()
+ {
+ }
+
+ public static IEnumerable<T> DeserializeItems<T>(Stream source, PrefixStyle style, int fieldNumber)
+ {
+ return RuntimeTypeModel.Default.DeserializeItems<T>(source, style, fieldNumber);
+ }
+
+ public static T DeserializeWithLengthPrefix<T>(Stream source, PrefixStyle style)
+ {
+ return Serializer.DeserializeWithLengthPrefix<T>(source, style, 0);
+ }
+
+ public static T DeserializeWithLengthPrefix<T>(Stream source, PrefixStyle style, int fieldNumber)
+ {
+ RuntimeTypeModel @default = RuntimeTypeModel.Default;
+ return (T)((object)@default.DeserializeWithLengthPrefix(source, null, @default.MapType(typeof(T)), style, fieldNumber));
+ }
+
+ public static T MergeWithLengthPrefix<T>(Stream source, T instance, PrefixStyle style)
+ {
+ RuntimeTypeModel @default = RuntimeTypeModel.Default;
+ return (T)((object)@default.DeserializeWithLengthPrefix(source, instance, @default.MapType(typeof(T)), style, 0));
+ }
+
+ public static void SerializeWithLengthPrefix<T>(Stream destination, T instance, PrefixStyle style)
+ {
+ Serializer.SerializeWithLengthPrefix<T>(destination, instance, style, 0);
+ }
+
+ public static void SerializeWithLengthPrefix<T>(Stream destination, T instance, PrefixStyle style, int fieldNumber)
+ {
+ RuntimeTypeModel @default = RuntimeTypeModel.Default;
+ @default.SerializeWithLengthPrefix(destination, instance, @default.MapType(typeof(T)), style, fieldNumber);
+ }
+
+ public static bool TryReadLengthPrefix(Stream source, PrefixStyle style, out int length)
+ {
+ int num;
+ int num2;
+ length = ProtoReader.ReadLengthPrefix(source, false, style, out num, out num2);
+ return num2 > 0;
+ }
+
+ public static bool TryReadLengthPrefix(byte[] buffer, int index, int count, PrefixStyle style, out int length)
+ {
+ bool result;
+ using (Stream stream = new MemoryStream(buffer, index, count))
+ {
+ result = Serializer.TryReadLengthPrefix(stream, style, out length);
+ }
+ return result;
+ }
+
+ public static void FlushPool()
+ {
+ BufferPool.Flush();
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializer.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializer.cs.meta new file mode 100644 index 00000000..f04470b3 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ee0c523c5c10b2346acfce15319ae03f +timeCreated: 1611404794 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers.meta new file mode 100644 index 00000000..c6dff761 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: c248e27ce1181c040af92086667ee0e6 +folderAsset: yes +timeCreated: 1611402943 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: 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<XDebug>.singleton.AddWarningLog("Warning: No ", (this.ExpectedType == null) ? "<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<XDebug>.singleton.AddErrorLog("Warning: No wire-value is mapped to the enum ", (value == null) ? "<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: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/SubItemToken.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/SubItemToken.cs new file mode 100644 index 00000000..7c7931ac --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/SubItemToken.cs @@ -0,0 +1,14 @@ +using System;
+
+namespace ProtoBuf
+{
+ public struct SubItemToken
+ {
+ internal readonly int value;
+
+ internal SubItemToken(int value)
+ {
+ this.value = value;
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/SubItemToken.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/SubItemToken.cs.meta new file mode 100644 index 00000000..a17fc881 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/SubItemToken.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: df34e0fc616583c428069d9235d73d5d +timeCreated: 1611404692 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/TimeSpanScale.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/TimeSpanScale.cs new file mode 100644 index 00000000..21502a03 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/TimeSpanScale.cs @@ -0,0 +1,15 @@ +using System;
+
+namespace ProtoBuf
+{
+ internal enum TimeSpanScale
+ {
+ Days,
+ Hours,
+ Minutes,
+ Seconds,
+ Milliseconds,
+ Ticks,
+ MinMax = 15
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/TimeSpanScale.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/TimeSpanScale.cs.meta new file mode 100644 index 00000000..ac617b0d --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/TimeSpanScale.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b7a52b65fa07a8b45b8d40f98e7c87a4 +timeCreated: 1611404402 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/WireType.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/WireType.cs new file mode 100644 index 00000000..29ee7af0 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/WireType.cs @@ -0,0 +1,16 @@ +using System;
+
+namespace ProtoBuf
+{
+ public enum WireType
+ {
+ None = -1,
+ Variant,
+ Fixed64,
+ String,
+ StartGroup,
+ EndGroup,
+ Fixed32,
+ SignedVariant = 8
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/WireType.cs.meta b/Client/Assets/Scripts/XMainClient/ProtoBuf/WireType.cs.meta new file mode 100644 index 00000000..a35fd116 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/WireType.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d843191b1a943424b934b60da2ebbf44 +timeCreated: 1611404638 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |