initial commit
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
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; }
|
||||
|
||||
public string KnownTypeName { get; }
|
||||
|
||||
public Type KnownType => TypeModel.ResolveKnownType(KnownTypeName, null, null);
|
||||
|
||||
[DefaultValue(DataFormat.Default)]
|
||||
public DataFormat DataFormat { get; set; }
|
||||
|
||||
public ProtoIncludeAttribute(int tag, Type knownType)
|
||||
: this(tag, ((object)knownType == null) ? "" : knownType.AssemblyQualifiedName)
|
||||
{
|
||||
}
|
||||
|
||||
public ProtoIncludeAttribute(int tag, string knownTypeName)
|
||||
{
|
||||
if (tag <= 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("tag", "Tags must be positive integers");
|
||||
}
|
||||
if (string.IsNullOrEmpty(knownTypeName))
|
||||
{
|
||||
throw new ArgumentNullException("knownTypeName", "Known type cannot be blank");
|
||||
}
|
||||
Tag = tag;
|
||||
KnownTypeName = knownTypeName;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user