Type of Dependency injection
- Constructor Injection (Inject to Class A contractor)
- Property Injection (Inject to Class A Property)
- Method Injection (Inject to Class A Method )
The code snippet you sent me defines a ServiceCollection which is used to register services that can be injected into other parts of the application. The AddSingleton(), AddScoped(), and AddTransient() methods are used to specify the lifetime of the registered services.
- AddSingleton() registers a service that will be created only once and used throughout the application.
- AddScoped() registers a service that will be created once per scope. A scope is typically a request or a web session.
- AddTransient() registers a service that will be created each time it is injected. The specific code you sent me does not register any services, but it shows the basic syntax for how to register services with different lifetimes.
Resule -