blob: 020fb23c49d78f5e0cbd6b2947841e1f4135ce3b (
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
69
70
71
72
73
|
using System;
using System.ComponentModel;
using ProtoBuf.Meta;
namespace ProtoBuf
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)]
public sealed class ProtoIncludeAttribute : Attribute
{
public int Tag
{
get
{
return this.tag;
}
}
public string KnownTypeName
{
get
{
return this.knownTypeName;
}
}
public Type KnownType
{
get
{
return TypeModel.ResolveKnownType(this.KnownTypeName, null, null);
}
}
[DefaultValue(DataFormat.Default)]
public DataFormat DataFormat
{
get
{
return this.dataFormat;
}
set
{
this.dataFormat = value;
}
}
private readonly int tag;
private readonly string knownTypeName;
private DataFormat dataFormat = DataFormat.Default;
public ProtoIncludeAttribute(int tag, Type knownType) : this(tag, (knownType == null) ? "" : knownType.AssemblyQualifiedName)
{
}
public ProtoIncludeAttribute(int tag, string knownTypeName)
{
bool flag = tag <= 0;
if (flag)
{
throw new ArgumentOutOfRangeException("tag", "Tags must be positive integers");
}
bool flag2 = Helpers.IsNullOrEmpty(knownTypeName);
if (flag2)
{
throw new ArgumentNullException("knownTypeName", "Known type cannot be blank");
}
this.tag = tag;
this.knownTypeName = knownTypeName;
}
}
}
|