Handling complex scenarios
If you've made it this far, then we can assume that you now have a better understanding of how the DI works and how you could implement them in different scenarios as required. In this section, we are going to look at some complex situations that you might face when writing your applications. We will see how we can apply the available options provided by the default DI containers to solve complex scenarios. Finally, we are going to look at how we can improve the organization of services when registering them in the DI container
Service descriptors
It's important to understand what service descriptors are before we dive into various complex scenarios.
Service descriptors contain information about the registered services that have been registered in the DI container, including the type of service, implementation, and lifetime. These are used internally by both IServiceCollection
and IServiceProvider
. It's very uncommon for us to work...