Skip to content

Shalini-lodhi/BlazorServer_DependencyInjection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dependency Injection (Blazor Server)

By Default it is in ASP.NET

  • allows to develop loosely-coupled code that is easy to maintain

  • redue dependencies among classes by injecting those dependencies at run-time instead of design time technically.

  • dependency injection is a way to create your dependencies outside of the class that uses it.

  • we inject them from the outside, and take control about their creation away from the inside of your class.

Why does one use dependency injection?

Drawbacks

  • We have to hard code everytime whenever we want to use any class/interface.
  1. Transient
  • objects are always different; a new instance is provided to every controller and every service.
  • single instance for the lifetime of the application domain.
  1. Scoped
  • objects are the same within a request, but different across different requests.
  • single instance for the duration of the scoped request, which means per HTTP request in ASP.NET
  1. Singleton
  • objects are the same for every object and every request.
  • single instance for the lifetime of the application domain. image

Releases

No releases published

Packages

No packages published