Of course, this behavior is possible thanks to the presence of a DI Container inside the ASP.NET Core engine. The official documentation states it very clearly: if a given type has declared that it has dependencies, and the container has been configured to provide the dependency types, it will create the dependencies as part of creating the requested instance.
The container, in this way, manages an object's lifetime and avoids the need for hard-coded object construction.
Besides other built-in implementations, remember that ASP.NET Core provides a simple DI Container (that we already tested in Chapter 3, Introducing Dependency Injection in .Net Core 2.0), represented by the IServiceProvider
interface.
As we mentioned, the place to configure services using that interface in this platform is the ConfigureServices
method, which we will analyze in the following section.