-
-
Notifications
You must be signed in to change notification settings - Fork 9
Simplify.DI.Microsoft.AspNetCore
Alexanderius edited this page Feb 28, 2021
·
5 revisions
How to replace 'Simplify.DI.Provider.Microsoft.Extensions.DependencyInjection' internal container with container from AspNetCore application
This allows us to perform registrations via Simplify.DI keeping original container in AspNetCore application
Install Simplify.DI.Provider.Microsoft.Extensions.DependencyInjection nuget package
In your Startup.cs
add this method
public IServiceProvider ConfigureServices(IServiceCollection services)
{
var provider = new MicrosoftDependencyInjectionDIProvider { Services = services };
DIContainer.Current = provider;
// Your registrations here (both via services or DIContainer.Current.Register)
return provider.ServiceProvider;
}
or
public void ConfigureServices(IServiceCollection services)
{
DIContainer.Current = new MicrosoftDependencyInjectionDIProvider { Services = services };
// Your registrations here (both via services or DIContainer.Current.Register)
}