I have an WinForms application with this Main Form :
ICountRepository countRepository;
public MainForm(ICountRepository countRepository)
{
this.countRepository = countRepository;
}
public void IncrementCount()
{
countRepository.IncrementCount();
}
but i am struggling to inject ICountRepository into the mainform. How do I do that ?
Well the first steps are to switch from:
to:
Perhaps a clarifying edit or two about what sort of thing you’re looking to achieve might get you a more detailed answer.
Highly recommended to get up to speed with the patterns around this is @Mark Seemann’s Dependency Injection in .NET book (in it’s parlance, the transformation above makes
Mainyour Composition Root – the (single)GetComposes the object graph of your app.