I know I can do something like
[SomeAttribute(typeof(SomeClass)]
public class SomeClass {}
From what I know I cannot get the type the attribute is applied to in any other way.
In the end I want to localize a string that is a descriptor of that class. Now I can use a static label to get the localized string from a resource file. I would simply use the type's name for that.
so my Attribute would have some property
public string Name => Properties.SomeNames.ResourceManager.GetString(_type.ToString());
Is this something that should be done in the attribute or in my reflection code that loads the types from an assembly?
I mean it is meta data for the type, so attribute should be a good place but on the other hand if I have to provide the type to the attribute first I don't win much right?
Any technical detail I'm missing or is this just preference?
Aucun commentaire:
Enregistrer un commentaire