Class UnityFallbackServiceProvider
Represents a service provider that first attempts to resolve services using the .NET Core's default dependency injection container, and if the service is not found, it falls back to the Unity container.
Implements
Inherited Members
Namespace: PoeShared.Blazor.Prism
Assembly: PoeShared.Blazor.dll
Syntax
public sealed class UnityFallbackServiceProvider : IServiceProvider
Remarks
The .NET Core's dependency injection container and Unity's container have different mechanisms for service registration and resolution. This service provider aims to bridge the gap between the two, allowing for a unified service resolution strategy that can work with both containers. However, it is important to be aware of the differences in lifetime management and other features between the two containers.
Unity Container: - Supports named registrations. - Allows more complex lifetime management including external control. - Provides property injection.
.NET Core DI Container: - Does not support named registrations out of the box. - Primarily supports three lifetimes - Singleton, Scoped, and Transient. - Focuses on constructor injection.
It is crucial to handle these differences carefully, especially for services with specific lifetime requirements or advanced configuration.
Constructors
Name | Description |
---|---|
UnityFallbackServiceProvider(IServiceProvider, IUnityContainer) | Initializes a new instance of the UnityFallbackServiceProvider class. |
Methods
Name | Description |
---|---|
GetService(Type) | Gets the service of the specified type from the .NET Core service provider or falls back to the Unity container if the service is not found. |