vendredi 16 octobre 2015

Get attribute type name without "Attribute"

typeof(UniqueFieldAttribute).Name returns UniqueFieldAttribute, but I want it to return UniqueField. If VS can resolve an attribute to its actual type without the substring Attribute in the name while it's decorating a class element, it seems that I would be able to get that resolvable name from some property on the type object.

I am aware that I could do this...

typeof(UniqueFieldAttribute).Name.Substring(0, typeof(UniqueFieldAttribute).Name.Length - 9)

...but I don't want to.





Aucun commentaire:

Enregistrer un commentaire