1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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);
}
}
}
|