123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- 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 ProtoIncludeAttribute(int tag, Type knownType)
- : this(tag, knownType == null ? "" : knownType.AssemblyQualifiedName) { }
-
-
-
-
-
- public ProtoIncludeAttribute(int tag, string knownTypeName)
- {
- if (tag <= 0) throw new ArgumentOutOfRangeException(nameof(tag), "Tags must be positive integers");
- if (string.IsNullOrEmpty(knownTypeName)) throw new ArgumentNullException(nameof(knownTypeName), "Known type cannot be blank");
- Tag = tag;
- KnownTypeName = knownTypeName;
- }
-
-
-
- public int Tag { get; }
-
-
-
- public string KnownTypeName { get; }
-
-
-
- public Type KnownType => TypeModel.ResolveKnownType(KnownTypeName, null, null);
-
-
-
-
- [DefaultValue(DataFormat.Default)]
- public DataFormat DataFormat { get; set; } = DataFormat.Default;
- }
- }
|