Question. Is there a way to get an instance of CustomAttributeData
based on the given instance of my custom attribute, say, MyAttribute
? Or vice versa?
Why do I need this? The instance of MyAttribute
contains properties I am interested in, while the instance of CustomAttributeData
contains actual constructor parameters I am interested in. So now I implement double work: first, get the instance of MyAttribute
by calling
Attribute.GetCustomAttribute(property, typeof(MyAttribute)) as MyAttribute
, and second, get the instance of CustomAttributeData
by calling
CustomAttributeData.GetCustomAttributes(property)
and walking over this collection.
P. S. I have taken a look on this question, but didn't find the desired solution there.
Aucun commentaire:
Enregistrer un commentaire