我有这个自定义属性:
[AttributeUsage(AttributeTargets.Method)]
public class MyAttribute : Attribute
{
public MyAttribute()
{
// I want to get the Test type in here.
// it could be any kind of type that one of its members uses this attribute.
}
}
我在某处使用 MyAtrribute。
public class Test
{
[MyAttribute]
public void MyMethod()
{
//method body
}
public string Name{get;set;}
public string LastName{get;set;}
}
我的问题是,我可以从 MyAttribute 的构造函数中获取测试类的其他成员吗?
谢谢您的帮助!