Please enable JavaScript.
Coggle requires JavaScript to display documents.
ASP.NET - Coggle Diagram
ASP.NET
Dependency Injection
Dependency
If class A depends on class B. Class B is termed as the "Dependency"
Inversion of control
Don’t call us, we’ll call you
Dependency inversion principle
Class should depend on abstraction (i.e., Interface)
Types
Constructor injection
Dependency Injection
example of DI in ASP.NET
Logger
Database
Authentication
Service lifetimes
Transient
created each time they're requested
Scoped
created once per client request (connection)
Eg. DbContext
Singleton
created the first time they're requested
Syntax
Add{LIFETIME}<{SERVICE}, {IMPLEMENTATION}>()