想象一下一个简单的属性类。该属性已在属性上使用 属性类可以“看到”它应用的位置吗?
[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; }
}