With C#6, using the nameof() keyword, it it now possible to create a type safe Display attribute that makes use of localization. (see also DisplayName attribute from Resources?)
The result will be something like this:
[Display(NameRes = Localization.Account.MinPasswordLength), ResourceType = typeof(Localization.Account))]
public int MinPasswordLength { get; set; }
But, after typing this for dozens of properties, I get the feeling there must be an easier way. Each time I am typing the same information twice (almost).
My question is this: How do I create a custom DisplayName attribute that infers the ResourceType from the Name information?
The code then would look something like this:
[Display(NameResource = Localization.Account.MinPasswordLength)]
public int MinPasswordLength { get; set; }
Any idea if this is possible? And if so: How?