1

単純な属性クラスを想像してください。属性がプロパティで使用されています。
属性クラスは適用された場所を「見る」ことができますか?

[AttributeUsage(AttributeTargets.Property)]
public class MyPropAttr : Attribute {
    public MyPropAttr () {
        PropName = ????; // default I was applied to prop X
    }
    public string SomeAttribute { get; set; }
    public string PropName { get; set; }   //<<<<<<<<< can this be determined ???
}

public class MyClass{
  [MyPropAttr(SomeAttribute="Bla")] 
  public string SomeFancyProp{ get; set; }
}
4

0 に答える 0