I have ViewModel classes like these that follow:
public class ReferenceDetailsViewModel
{
public ReferenceDetailsViewModel() {
this.Timer = new List<long>();
}
public IEnumerable<Reference.Grid> Grid { get; set; }
public List<long> Timer { get; set; }
}
public class ContentDetailsViewModel
{
public ContentDetailsViewModel() {
this.Timer = new List<long>();
}
public IEnumerable<Content.Grid> Detail { get; set; }
public SelectList Statuses { get; set; }
public SelectList Types { get; set; }
public List<long> Timer { get; set; }
}
They all have in common a Timer field and this is initialized in the constructor.
Is there a way that I could create a baseViewModel and have these inherit the Timer field so as to avoid coding the same thing for each ViewModel that has a timer ?
Yes, code an abstract class and make concrete classes inherit from this.