blob: 956838552265155cd874c2a079c25c972df7f8c8 (
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
57
58
59
60
61
62
63
64
65
66
67
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;
}
}
}
|