An implementation of a dependency injection framework adapter that pulls dependencies from a global IServiceProvider exposed on the ServiceProviderProvider class.
Implements
Namespace: Metalama.Extensions.DependencyInjection.ServiceLocator
Assembly: Metalama.Extensions.DependencyInjection.ServiceLocator.dll
Syntax
[CompileTime]
public class ServiceLocatorDependencyInjectionFramework : DefaultDependencyInjectionFramework, IDependencyInjectionFrameworkRemarks
This framework adapter implements a service locator pattern, where dependencies are resolved from a global service provider rather than being injected through constructors. This approach can be useful for legacy code or scenarios where constructor injection is not practical, though constructor injection is generally preferred when possible.
This framework is automatically registered when you add a reference to the Metalama.Extensions.DependencyInjection.ServiceLocator package.
To use it, ensure the ServiceProviderProvider is configured with your application's IServiceProvider.
Constructors
| Name | Description |
|---|---|
| ServiceLocatorDependencyInjectionFramework() |
Methods
| Name | Description |
|---|---|
| GetStrategy(DependencyProperties) | Gets an instance of the DefaultDependencyInjectionStrategy class for a given context. |