samedi 19 octobre 2019

Retrieve enclosing property's attribute

Assume I have a class like

class A {
 [MyAnnotation("foobar")]
 B B { get; set; }
}

and

class B {
 int x { get; set; }
}

If I have reference to x, is it possible to access the custom attribute of B?

Something like

var a = new A();
var v = a.B.x;
console.log(v.GetParentCustomAttribute())

>> foobar




Aucun commentaire:

Enregistrer un commentaire