I’m looking for a simpler/drier way to use ressources my MVC 3 models.
This is how I’m doing it now (Each attribute needs to be told which ressource type it uses):
public class ContactMessageModel:BaseModel
{
[Display(Name="ReplyToEmail_DisplayName", ResourceType = typeof(Res.Views_Contact))]
public string ReplyToEmail {get; set; }
[Display(Name = "ContactReason_DisplayName", ResourceType = typeof(Res.Views_Contact))]
public string ContactReason { get; set; }
Can this be done?
This is how I’d like to do it (I just want to define the resource type for the model once):
[Display(ResourceType = typeof(Res.Views_Contact))]
public class ContactMessageModel:BaseModel
{
[Display(Name="ReplyToEmail_DisplayName")]
public string ReplyToEmail {get; set; }
[Display(Name = "ContactReason_DisplayName")]
public string ContactReason { get; set; }
Doesn’t seem possible, because the attribute instance would require access to the property it is sitting on, which .NET does not support.