Previously I was using Unity for dependency injection, and it automatically resolved dependency's for me that code looked something like this:
IUnityContainer UnityContainer = new UnityContainer();
UnityContainer.RegisterType<IDataProvider, DataProvider>();
Some class to have IDataProvider injected into:
public class SomeClass
{
private IDataProvider dataProvider;
public SomeClass(IDataProvider dataProvider)
{
this.dataProvider = dataProvider;
}
}
To resolve the dependencies for this object with unity I could simply type
SomeClass myClass = Unity.Resolve<SomeClass>();
And it would automatically try to inject the required constructor parameters from its ServiceCollection. Due to Unity being depreciated now, I've been trying to make the switch to Microsoft.Extensions.DependencyInjection, I've got the IServiceProvider setup and can return requested services, however I'm yet to figure out how to use this library (and if I need extra librarys for this functionality) top achieve the same result.