Class ServiceProviderFactory
Represents various ways for building IServiceProvider implementations.
Inherited Members
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class ServiceProviderFactory
Fields
| Improve this Doc View SourceEmpty
Represents empty service provider.
Declaration
public static readonly IServiceProvider Empty
Field Value
Type | Description |
---|---|
IServiceProvider |
Methods
| Improve this Doc View SourceCreate<T>(T, IServiceProvider)
Creates service provider containing the single service.
Declaration
public static IServiceProvider Create<T>(T service, IServiceProvider fallback = null)
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. |
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)
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. |
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)
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. |
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)
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. |
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)
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. |
CreateDelegatingFactory(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.
CreateDelegatingFactory<T>()
Creates factory that can be used to construct delegating service provider.
Declaration
public static Func<T, IServiceProvider, IServiceProvider> CreateDelegatingFactory<T>()
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. |
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>()
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. |
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>()
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. |
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>()
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. |
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>()
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. |
CreateFactory(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.
CreateFactory<T>()
Creates factory that can be used to construct the service provider.
Declaration
public static Func<T, IServiceProvider> CreateFactory<T>()
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. |
CreateFactory<T1, T2>()
Creates factory that can be used to construct the service provider.
Declaration
public static Func<T1, T2, IServiceProvider> CreateFactory<T1, T2>()
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. |
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>()
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. |
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>()
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. |
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>()
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. |
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. |