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/Serializers/SubItemSerializer.cs |
+scripts
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SubItemSerializer.cs')
-rw-r--r-- | Client/Assets/Scripts/XMainClient/ProtoBuf/Serializers/SubItemSerializer.cs | 96 |
1 files changed, 96 insertions, 0 deletions
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);
+ }
+ }
+}
|