blob: 6dd8be7235e05eeeec3ed331b1338d975bf942bf (
plain)
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
|
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);
}
}
}
|