Summary
Using the approaches we have demonstrated in this chapter, you will be able to use any .NET Standard-compatible DI container to replace the existing one. If the container of your choice doesn't include a ServiceProvider
, create your own that implements IServiceProvider
and uses the DI container inside. If the container of your choice doesn't provide a method to populate the registered services in the container, create your own method. Loop over the registered services and add them to the other container.
Actually, the last step sounds easy, but can be a hard task, because you need to translate all the possible IServiceCollection
registrations into registrations of the different container. The complexity of that task depends on the implementation details of the other DI container.
Anyway, you have the choice to use any DI container that is compatible with the .NET Standard. You can change a lot of the default implementations in ASP.NET Core.
This is also something...