カスタム属性のクラス内で装飾されたクラスの型を取得することは可能ですか? 例えば:
[MetadataAttribute]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = false)]
public class ViewAttribute : ExportAttribute
{
public object TargetRegion { get; set; }
public Type ViewModel { get; set; }
public Type Module { get; set; }
public ViewAttribute()
: base(typeof(UserControl))
{
Module = GetDecoratedClassType(); //I need this method
}
}
次の例では、GetDecoratedClassType() は HomeView を返します。
[View]
HomeView MyHomeView { get; set; }