Class ServiceProviderFactory
Represents various ways for building IServiceProvider implementations.
Inherited Members
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class ServiceProviderFactory
Methods
View SourceCreateBuilder()
Creates a builder of the custom IServiceProvider implementation.
Declaration
public static ServiceProviderFactory.Builder CreateBuilder()
Returns
| Type | Description |
|---|---|
| ServiceProviderFactory.Builder | The builder instance. |
Create<T>(T, IServiceProvider?)
Creates service provider from the tuple.
Declaration
public static IServiceProvider Create<T>(T tuple, IServiceProvider? fallback = null) where T : struct, ITuple
Parameters
| Type | Name | Description |
|---|---|---|
| T | tuple | The tuple containing services. |
| IServiceProvider | fallback | The fallback provider used for service resolution if tuple doesn't contain the requested service. |
Returns
| Type | Description |
|---|---|
| IServiceProvider | The service provider constructed from the tuple. |
Type Parameters
| Name | Description |
|---|---|
| T | The tuple type representing a set of services. |
Override<TService>(IServiceProvider, ISupplier<TService>)
Overrides the service that can be returned by the underlying service provider.
Declaration
public static IServiceProvider Override<TService>(this IServiceProvider provider, ISupplier<TService> serviceGetter) where TService : class
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceProvider | provider | |
| ISupplier<TService> | serviceGetter | The service instance getter. |
Returns
| Type | Description |
|---|---|
| IServiceProvider | A new service provider that returns the result of |
Type Parameters
| Name | Description |
|---|---|
| TService | The type of the service. |
Override<TService>(IServiceProvider, Func<TService>)
Overrides the service that can be returned by the underlying service provider.
Declaration
public static IServiceProvider Override<TService>(this IServiceProvider provider, Func<TService> serviceGetter) where TService : class
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceProvider | provider | |
| Func<TService> | serviceGetter | The service instance getter. |
Returns
| Type | Description |
|---|---|
| IServiceProvider | A new service provider that returns the result of |
Type Parameters
| Name | Description |
|---|---|
| TService | The type of the service. |
Override<TService>(IServiceProvider, TService)
Overrides the service that can be returned by the underlying service provider.
Declaration
public static IServiceProvider Override<TService>(this IServiceProvider provider, TService service) where TService : notnull
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceProvider | provider | |
| TService | service | The service instance. |
Returns
| Type | Description |
|---|---|
| IServiceProvider | A new service provider that returns |
Type Parameters
| Name | Description |
|---|---|
| TService | The type of the service. |
get_Empty()
Gets the empty service provider.
Declaration
public static IServiceProvider get_Empty()
Returns
| Type | Description |
|---|---|
| IServiceProvider |