There is the MetadataTypeAttribute to specify the metadata class to associate with a data model class. So, I can define metadata, that help render HTML controls in an MVC application, within an associated class from another file. For example:
User.cs
[MetadataType(typeof(UserMetaData))]
public partial class User
{
public string FirstName { get; set; }
public string LastName { get; set; }
public DateTime BirthDate { get; set; }
}
MetaData.cs
public partial class UserMetaData
{
[HiddenInput(DisplayValue = false)]
public int UserId { get; set; }
[DisplayName("Your Name")]
public string FirstName { get; set; }
[DisplayName("Your Last Name")]
public string LastName { get; set; }
}
Is there similar way to define JsonProperty attributes for my model's properties in another file?