クラスに割り当てることができるカスタム属性があります[FooAttribute]
。私がやりたいことは、属性内から、どのタイプが実際に私を使用したかを判断することです。たとえば、私が持っている場合:
[FooAttribute]
public class Bar
{
}
FooAttribute のコードで、私を追加したのが Bar クラスであったことをどのように判断できますか? 特に Bar タイプを探しているわけではありません。リフレクションを使用してわかりやすい名前を設定したいだけです。例えば
[FooAttribute(Name="MyFriendlyNameForThisClass")]
public class Bar
{
}
public class FooAttribute()
{
public FooAttribute()
{
// How do I get the target types name? (as a default)
}
}