From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../XMainClient/ProtoBuf/ProtoIncludeAttribute.cs | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoIncludeAttribute.cs (limited to 'Client/Assets/Scripts/XMainClient/ProtoBuf/ProtoIncludeAttribute.cs') 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; + } + } +} -- cgit v1.1-26-g67d0