Show / Hide Table of Contents

Class ServiceProviderFactory

Represents various ways for building IServiceProvider implementations.

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

Fields

| Edit this page View Source

Empty

Represents empty service provider.

Declaration
public static readonly IServiceProvider Empty
Field Value
Type Description
IServiceProvider

Methods

| Edit this page View Source

CreateDelegatingFactory(params Type[])

Creates factory that can be used to construct delegating service provider.

Declaration
public static Func<object[], IServiceProvider, IServiceProvider> CreateDelegatingFactory(params Type[] types)
Parameters
Type Name Description
Type[] types

The array of supported types by the service provider.

Returns
Type Description
Func<object[], IServiceProvider, IServiceProvider>

The delegate that can be used to instantiate specialized service provider.

Remarks

The constructed factory compiles specialization of the service provider on-the-fly using dynamic code compilation technique when applicable. If dynamic code compilation is not supported then the factory uses the implementation backed by dictionary.

| Edit this page View Source

CreateDelegatingFactory<T>()

Creates factory that can be used to construct delegating service provider.

Declaration
public static Func<T, IServiceProvider, IServiceProvider> CreateDelegatingFactory<T>() where T : notnull
Returns
Type Description
Func<T, IServiceProvider, IServiceProvider>

The factory that can be used to construct the service provider.

Type Parameters
Name Description
T

The type of the service that can be returned by the provider.

| Edit this page View Source

CreateDelegatingFactory<T1, T2>()

Creates factory that can be used to construct delegating service provider.

Declaration
public static Func<T1, T2, IServiceProvider, IServiceProvider> CreateDelegatingFactory<T1, T2>() where T1 : notnull where T2 : notnull
Returns
Type Description
Func<T1, T2, IServiceProvider, IServiceProvider>

The factory that can be used to construct the service provider.

Type Parameters
Name Description
T1

The type of the first service that can be returned by the provider.

T2

The type of the second service that can be returned by the provider.

| Edit this page View Source

CreateDelegatingFactory<T1, T2, T3>()

Creates factory that can be used to construct delegating service provider.

Declaration
public static Func<T1, T2, T3, IServiceProvider, IServiceProvider> CreateDelegatingFactory<T1, T2, T3>() where T1 : notnull where T2 : notnull where T3 : notnull
Returns
Type Description
Func<T1, T2, T3, IServiceProvider, IServiceProvider>

The factory that can be used to construct the service provider.

Type Parameters
Name Description
T1

The type of the first service that can be returned by the provider.

T2

The type of the second service that can be returned by the provider.

T3

The type of the third service that can be returned by the provider.

| Edit this page View Source

CreateDelegatingFactory<T1, T2, T3, T4>()

Creates factory that can be used to construct delegating service provider.

Declaration
public static Func<T1, T2, T3, T4, IServiceProvider, IServiceProvider> CreateDelegatingFactory<T1, T2, T3, T4>() where T1 : notnull where T2 : notnull where T3 : notnull where T4 : notnull
Returns
Type Description
Func<T1, T2, T3, T4, IServiceProvider, IServiceProvider>

The factory that can be used to construct the service provider.

Type Parameters
Name Description
T1

The type of the first service that can be returned by the provider.

T2

The type of the second service that can be returned by the provider.

T3

The type of the third service that can be returned by the provider.

T4

The type of the fourth service that can be returned by the provider.

| Edit this page View Source

CreateDelegatingFactory<T1, T2, T3, T4, T5>()

Creates factory that can be used to construct delegating service provider.

Declaration
public static Func<T1, T2, T3, T4, T5, IServiceProvider, IServiceProvider> CreateDelegatingFactory<T1, T2, T3, T4, T5>() where T1 : notnull where T2 : notnull where T3 : notnull where T4 : notnull where T5 : notnull
Returns
Type Description
Func<T1, T2, T3, T4, T5, IServiceProvider, IServiceProvider>

The factory that can be used to construct the service provider.

Type Parameters
Name Description
T1

The type of the first service that can be returned by the provider.

T2

The type of the second service that can be returned by the provider.

T3

The type of the third service that can be returned by the provider.

T4

The type of the fourth service that can be returned by the provider.

T5

The type of the fifth service that can be returned by the provider.

| Edit this page View Source

CreateFactory(params Type[])

Creates factory that can be used to construct the service provider.

Declaration
public static Func<object[], IServiceProvider> CreateFactory(params Type[] types)
Parameters
Type Name Description
Type[] types

The array of supported types by the service provider.

Returns
Type Description
Func<object[], IServiceProvider>

The delegate that can be used to instantiate specialized service provider.

Remarks

The constructed factory compiles specialization of the service provider on-the-fly using dynamic code compilation technique when applicable. If dynamic code compilation is not supported then the factory uses the implementation backed by dictionary.

| Edit this page View Source

CreateFactory<T>()

Creates factory that can be used to construct the service provider.

Declaration
public static Func<T, IServiceProvider> CreateFactory<T>() where T : notnull
Returns
Type Description
Func<T, IServiceProvider>

The factory that can be used to construct the service provider.

Type Parameters
Name Description
T

The type of the service that can be returned by the provider.

| Edit this page View Source

CreateFactory<T1, T2>()

Creates factory that can be used to construct the service provider.

Declaration
public static Func<T1, T2, IServiceProvider> CreateFactory<T1, T2>() where T1 : notnull where T2 : notnull
Returns
Type Description
Func<T1, T2, IServiceProvider>

The factory that can be used to construct the service provider.

Type Parameters
Name Description
T1

The type of the first service that can be returned by the provider.

T2

The type of the second service that can be returned by the provider.

| Edit this page View Source

CreateFactory<T1, T2, T3>()

Creates factory that can be used to construct the service provider.

Declaration
public static Func<T1, T2, T3, IServiceProvider> CreateFactory<T1, T2, T3>() where T1 : notnull where T2 : notnull where T3 : notnull
Returns
Type Description
Func<T1, T2, T3, IServiceProvider>

The factory that can be used to construct the service provider.

Type Parameters
Name Description
T1

The type of the first service that can be returned by the provider.

T2

The type of the second service that can be returned by the provider.

T3

The type of the third service that can be returned by the provider.

| Edit this page View Source

CreateFactory<T1, T2, T3, T4>()

Creates factory that can be used to construct the service provider.

Declaration
public static Func<T1, T2, T3, T4, IServiceProvider> CreateFactory<T1, T2, T3, T4>() where T1 : notnull where T2 : notnull where T3 : notnull where T4 : notnull
Returns
Type Description
Func<T1, T2, T3, T4, IServiceProvider>

The factory that can be used to construct the service provider.

Type Parameters
Name Description
T1

The type of the first service that can be returned by the provider.

T2

The type of the second service that can be returned by the provider.

T3

The type of the third service that can be returned by the provider.

T4

The type of the fourth service that can be returned by the provider.

| Edit this page View Source

CreateFactory<T1, T2, T3, T4, T5>()

Creates factory that can be used to construct the service provider.

Declaration
public static Func<T1, T2, T3, T4, T5, IServiceProvider> CreateFactory<T1, T2, T3, T4, T5>() where T1 : notnull where T2 : notnull where T3 : notnull where T4 : notnull where T5 : notnull
Returns
Type Description
Func<T1, T2, T3, T4, T5, IServiceProvider>

The factory that can be used to construct the service provider.

Type Parameters
Name Description
T1

The type of the first service that can be returned by the provider.

T2

The type of the second service that can be returned by the provider.

T3

The type of the third service that can be returned by the provider.

T4

The type of the fourth service that can be returned by the provider.

T5

The type of the fifth service that can be returned by the provider.

| Edit this page View Source

Create<T>(T, IServiceProvider?)

Creates service provider containing the single service.

Declaration
public static IServiceProvider Create<T>(T service, IServiceProvider? fallback = null) where T : notnull
Parameters
Type Name Description
T service

The service instance.

IServiceProvider fallback

The fallback provider used for service resolution if requested service type is not supported by the constructed provider.

Returns
Type Description
IServiceProvider

The service provider.

Type Parameters
Name Description
T

The type of the service.

| Edit this page View Source

Create<T1, T2>(T1, T2, IServiceProvider?)

Creates service provider containing the two services.

Declaration
public static IServiceProvider Create<T1, T2>(T1 service1, T2 service2, IServiceProvider? fallback = null) where T1 : notnull where T2 : notnull
Parameters
Type Name Description
T1 service1

The first service.

T2 service2

The second service.

IServiceProvider fallback

The fallback provider used for service resolution if requested service type is not supported by the constructed provider.

Returns
Type Description
IServiceProvider

The service provider.

Type Parameters
Name Description
T1

The type of the first service.

T2

The type of the second service.

| Edit this page View Source

Create<T1, T2, T3>(T1, T2, T3, IServiceProvider?)

Creates service provider containing the three services.

Declaration
public static IServiceProvider Create<T1, T2, T3>(T1 service1, T2 service2, T3 service3, IServiceProvider? fallback = null) where T1 : notnull where T2 : notnull where T3 : notnull
Parameters
Type Name Description
T1 service1

The first service.

T2 service2

The second service.

T3 service3

The third service.

IServiceProvider fallback

The fallback provider used for service resolution if requested service type is not supported by the constructed provider.

Returns
Type Description
IServiceProvider

The service provider.

Type Parameters
Name Description
T1

The type of the first service.

T2

The type of the second service.

T3

The type of the third service.

| Edit this page View Source

Create<T1, T2, T3, T4>(T1, T2, T3, T4, IServiceProvider?)

Creates service provider containing the four services.

Declaration
public static IServiceProvider Create<T1, T2, T3, T4>(T1 service1, T2 service2, T3 service3, T4 service4, IServiceProvider? fallback = null) where T1 : notnull where T2 : notnull where T3 : notnull where T4 : notnull
Parameters
Type Name Description
T1 service1

The first service.

T2 service2

The second service.

T3 service3

The third service.

T4 service4

The fourth service.

IServiceProvider fallback

The fallback provider used for service resolution if requested service type is not supported by the constructed provider.

Returns
Type Description
IServiceProvider

The service provider.

Type Parameters
Name Description
T1

The type of the first service.

T2

The type of the second service.

T3

The type of the third service.

T4

The type of the fourth service.

| Edit this page View Source

Create<T1, T2, T3, T4, T5>(T1, T2, T3, T4, T5, IServiceProvider?)

Creates service provider containing the four services.

Declaration
public static IServiceProvider Create<T1, T2, T3, T4, T5>(T1 service1, T2 service2, T3 service3, T4 service4, T5 service5, IServiceProvider? fallback = null) where T1 : notnull where T2 : notnull where T3 : notnull where T4 : notnull where T5 : notnull
Parameters
Type Name Description
T1 service1

The first service.

T2 service2

The second service.

T3 service3

The third service.

T4 service4

The fourth service.

T5 service5

The fifth service.

IServiceProvider fallback

The fallback provider used for service resolution if requested service type is not supported by the constructed provider.

Returns
Type Description
IServiceProvider

The service provider.

Type Parameters
Name Description
T1

The type of the first service.

T2

The type of the second service.

T3

The type of the third service.

T4

The type of the fourth service.

T5

The type of the fifth service.

| Edit this page View Source

FromTuple<T>(T, IServiceProvider?)

Creates service provider from the tuple.

Declaration
public static IServiceProvider FromTuple<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.

  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾