我有我的
class BaseClass
{
}
和两个像这样的子类:
[PostTransformer("test", Precedence=5)]
class SubClassA : BaseClass
{
}
和一个属性
[System.AttributeUsage(System.AttributeTargets.Class)]
public class PostTransformerAttribute : Attribute
{
public int Precedence;
public string Title;
public PostTransformerAttribute(string Title)
{
this.Title = Title;
Precedence = int.MaxValue;
}
}
如何获取PostTransformerAttribute
BaseClass 的所有子类的类型的所有属性?
我努力了:
var test = typeof(BaseClass).GetTypeInfo().GetCustomAttributes<PostTransformerAttribute>();
但它返回了一个空数组。