summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoIncludeAttribute.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoIncludeAttribute.cs')
-rw-r--r--Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoIncludeAttribute.cs73
1 files changed, 73 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoIncludeAttribute.cs b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoIncludeAttribute.cs
new file mode 100644
index 00000000..020fb23c
--- /dev/null
+++ b/Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoIncludeAttribute.cs
@@ -0,0 +1,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;
+ }
+ }
+}