Skip to content

Latest commit

 

History

History
 
 

dependency-injection

Dependency Injection (4)

ASP.NET Core lives and dies by DI. It relies on Microsoft.Extensions.DependencyInjection library.

  • Dependency Injection 1 - The basic

    Demonstrate the three lifetime registrations for the out of the box DI functionality: singleton (one and only forever), scoped (one in every request) and transient (new everytime).

  • Dependency Injection 2 - IServiceProvider

    IServiceProvider is a service locator. It allows you to obtain objects from the dependency injection system.

  • Dependency Injection 3 - Easy registration

    Register all objects configured by classes that implements a specific interface (IBootstrap in this example). This is useful when you have large amount of classes in your project that needs registration. You can register them near where they are (usually in the same folder) instead of registering them somewhere in a giant registration function.

  • Lazy Type

    This shows how to register Lazy types in the built in Dependency Injection.

dotnet6