You need to use type.GetTypeInfo()
, which then has various GetCustomAttribute
methods (via extension methods), or there is .CustomAttributes
which gives you the raw information (rather than materialized Attribute
instances).
For example:
var attribute = type.GetTypeInfo().GetCustomAttribute<WrapperObjectAttribute>();
if(attribute == null)
{
...
}
...
GetTypeInfo()
is the pain of .NETCore for library authors ;p
If .GetTypeInfo()
doesn't appear, then add a using System.Reflection;
directive.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…