Implementation Discovery is a helper library that extends the options of Microsoft.Extensions.DependencyInjection with functions for discovering the implementations of your service and injecting it.
public void ConfigureServices(IServiceCollection services)
{
//... other services
service.MapImplementationsOf<IExampleInterface>().AsScoped();
}
public void ConfigureServices(IServiceCollection services)
{
//... other services
service.MapImplementationsOf(typeof(IExampleInterface<,>)).AsTransient();
}
You can inject them with AsTransient()
, AsScoped()
or AsSingleton()
.