Show / Hide Table of Contents

Class ServiceProviderFactory

Represents various ways for building IServiceProvider implementations.

Inheritance
object
ServiceProviderFactory
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class ServiceProviderFactory

Methods

View Source

CreateBuilder()

Creates a builder of the custom IServiceProvider implementation.

Declaration
public static ServiceProviderFactory.Builder CreateBuilder()
Returns
Type Description
ServiceProviderFactory.Builder

The builder instance.

View Source

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.

View Source

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 serviceGetter invocation if the requested type is TService.

Type Parameters
Name Description
TService

The type of the service.

View Source

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 serviceGetter invocation if the requested type is TService.

Type Parameters
Name Description
TService

The type of the service.

View Source

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 service if the requested type is TService.

Type Parameters
Name Description
TService

The type of the service.

View Source

get_Empty()

Gets the empty service provider.

Declaration
public static IServiceProvider get_Empty()
Returns
Type Description
IServiceProvider
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾