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