public interface IViewModelBuilder<T> where T : IViewModel
{
}
You are using this (im guessing) to register all ViewModelbuilders.
The generic type is here declarated to be of type IViewModel.
So far so good, straight forward im with you.
But when we come to the HeadViewModelBuilder (as one example) you have declarated it as below:
public class HeadViewModelBuilder<TViewModel> : IViewModelBuilder<TViewModel>
where TViewModel : HeadViewModel
but I don’t see why it’s not just
public class HeadViewModelBuilder : IViewModelBuilder<HeadViewModel>
Like almost every other ViewModelBuilder.
So why is there a declaration like this for this one and a few others, why are there a few exception from the rest of the viewmodel builders?
As the code in accelerator is build today we don’t have a need; except service registration, for having the IViewModelBuilder because we are always injecting the correct type of the builder in their usage.
For the specific example the code is multiple years old and I don’t remember all small details from that time but I guess that it was because of we having multiple headers, small and large, and there was created with a common base class like SmallHeadViewModel : HeadViewModel and LargeHeadViewModel : HeadViewModel so the result can be different from the same builder that was using the correct type through AutoMapper.