Class ServiceConfigurationProviderExtensions
Provides extension methods for IServiceConfigurationProvider implemenations.
Inheritance
Namespace: EPiServer.ServiceLocation
Assembly: EPiServer.Framework.dll
Version: 12.0.3Syntax
public static class ServiceConfigurationProviderExtensions : Object
Methods
Add(IServiceConfigurationProvider, ServiceDescriptor)
Registers a service as described by ServiceDescriptor
Declaration
public static IRegisteredService Add(this IServiceConfigurationProvider services, ServiceDescriptor descriptor)
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
ServiceDescriptor | descriptor | The service descriptor |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Add(IServiceConfigurationProvider, Type, Func<IServiceLocator, Object>, ServiceInstanceScope)
Registers implementation factory for a service
Declaration
public static IRegisteredService Add(this IServiceConfigurationProvider services, Type serviceType, Func<IServiceLocator, object> implementationFactory, ServiceInstanceScope serviceInstanceScope)
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Type | serviceType | The service type |
System.Func<IServiceLocator, System.Object> | implementationFactory | The implementation factory |
ServiceInstanceScope | serviceInstanceScope | The service instance scope |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Add(IServiceConfigurationProvider, Type, Type, ServiceInstanceScope)
Registers a transient lifecycled implementation for a service
Declaration
public static IRegisteredService Add(this IServiceConfigurationProvider services, Type serviceType, Type implementationType, ServiceInstanceScope serviceInstanceScope)
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Type | serviceType | The service type |
System.Type | implementationType | The implementation type |
ServiceInstanceScope | serviceInstanceScope | The scope of service instances |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Add<TService>(IServiceConfigurationProvider, Func<IServiceLocator, TService>, ServiceInstanceScope)
Registers lifecycled implementation factory for a service
Declaration
public static IRegisteredService Add<TService>(this IServiceConfigurationProvider services, Func<IServiceLocator, TService> implementationFactory, ServiceInstanceScope serviceInstanceScope)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Func<IServiceLocator, TService> | implementationFactory | The implementation factory |
ServiceInstanceScope | serviceInstanceScope | The service instance scope |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService |
Add<TService, TImplementation>(IServiceConfigurationProvider, ServiceInstanceScope)
Registers a singleton lifecycled type for a service
Declaration
public static IRegisteredService Add<TService, TImplementation>(this IServiceConfigurationProvider services, ServiceInstanceScope serviceInstanceScope)
where TService : class where TImplementation : class, TService
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
ServiceInstanceScope | serviceInstanceScope | The service instance scope |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService | |
TImplementation |
AddHttpContextOrThreadScoped<TService>(IServiceConfigurationProvider, Func<IServiceLocator, TService>)
Registers a hybrid (httpcontext or thread local) lifecycled factory for a service.
Declaration
public static IRegisteredService AddHttpContextOrThreadScoped<TService>(this IServiceConfigurationProvider services, Func<IServiceLocator, TService> implementationFactory)
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Func<IServiceLocator, TService> | implementationFactory | The factory |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService | The service type |
AddHttpContextOrThreadScoped<TService, TImpl>(IServiceConfigurationProvider)
Registers a hybrid (httpcontext or thread local) lifecycled implementation type for a service
Declaration
public static IRegisteredService AddHttpContextOrThreadScoped<TService, TImpl>(this IServiceConfigurationProvider services)
where TImpl : TService
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService | The service type |
TImpl | The implementation type |
AddHttpContextScoped<TService>(IServiceConfigurationProvider, Func<IServiceLocator, TService>)
Registers a http context lifecycled factory for a service
Declaration
public static IRegisteredService AddHttpContextScoped<TService>(this IServiceConfigurationProvider services, Func<IServiceLocator, TService> implementationFactory)
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Func<IServiceLocator, TService> | implementationFactory | The implementation factory |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService | The service type |
AddHttpContextScoped<TService, TImpl>(IServiceConfigurationProvider)
Registers a http context lifecycled implementation type for a service
Declaration
public static IRegisteredService AddHttpContextScoped<TService, TImpl>(this IServiceConfigurationProvider services)
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService | The service type |
TImpl | The implementation type |
AddScoped(IServiceConfigurationProvider, Type)
Registers a hybrid (httpcontext or thread local) lifecycled concrete type as a service
Declaration
public static IRegisteredService AddScoped(this IServiceConfigurationProvider services, Type serviceType)
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Type | serviceType | The service type |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
AddScoped(IServiceConfigurationProvider, Type, Func<IServiceLocator, Object>)
Registers a hybrid (httpcontext or thread local) lifecycled instance factory as a service
Declaration
public static IRegisteredService AddScoped(this IServiceConfigurationProvider services, Type serviceType, Func<IServiceLocator, object> implementationFactory)
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Type | serviceType | The service type |
System.Func<IServiceLocator, System.Object> | implementationFactory | The implementation factory |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
AddScoped(IServiceConfigurationProvider, Type, Type)
Registers a hybrid (httpcontext or thread local) lifecycled instance as a service
Declaration
public static IRegisteredService AddScoped(this IServiceConfigurationProvider services, Type serviceType, Type implementationType)
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Type | serviceType | The service type |
System.Type | implementationType | The implementation type |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
AddScoped<TService>(IServiceConfigurationProvider)
Registers a hybrid (httpcontext or thread local) lifecycled concrete type as a service
Declaration
public static IRegisteredService AddScoped<TService>(this IServiceConfigurationProvider services)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService |
AddScoped<TService>(IServiceConfigurationProvider, Func<IServiceLocator, TService>)
Registers a hybrid (httpcontext or thread local) lifecycled factory as a service
Declaration
public static IRegisteredService AddScoped<TService>(this IServiceConfigurationProvider services, Func<IServiceLocator, TService> implementationFactory)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Func<IServiceLocator, TService> | implementationFactory | The instance factory |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService |
AddScoped<TService, TImplementation>(IServiceConfigurationProvider)
Registers a hybrid (httpcontext or thread local) lifecycled instance as a service
Declaration
public static IRegisteredService AddScoped<TService, TImplementation>(this IServiceConfigurationProvider services)
where TService : class where TImplementation : class, TService
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService | |
TImplementation |
AddScoped<TService, TImplementation>(IServiceConfigurationProvider, Func<IServiceLocator, TImplementation>)
Registers a hybrid (httpcontext or thread local) lifecycled factory as a service
Declaration
public static IRegisteredService AddScoped<TService, TImplementation>(this IServiceConfigurationProvider services, Func<IServiceLocator, TImplementation> implementationFactory)
where TService : class where TImplementation : class, TService
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Func<IServiceLocator, TImplementation> | implementationFactory | The instance factory |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService | |
TImplementation |
AddSingleton(IServiceConfigurationProvider, Type)
Registers a singleton lifecycled concrete type as a service
Declaration
public static IRegisteredService AddSingleton(this IServiceConfigurationProvider services, Type serviceType)
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Type | serviceType | The service type |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
AddSingleton(IServiceConfigurationProvider, Type, Func<IServiceLocator, Object>)
Registers a singleton lifecycled factory for a service
Declaration
public static IRegisteredService AddSingleton(this IServiceConfigurationProvider services, Type serviceType, Func<IServiceLocator, object> implementationFactory)
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Type | serviceType | The service type |
System.Func<IServiceLocator, System.Object> | implementationFactory | The implementation factory |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
AddSingleton(IServiceConfigurationProvider, Type, Object)
Registers a singleton lifecycled instance as a service
Declaration
public static IRegisteredService AddSingleton(this IServiceConfigurationProvider services, Type serviceType, object implementationInstance)
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Type | serviceType | The service type |
System.Object | implementationInstance | The singleton instance |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
AddSingleton(IServiceConfigurationProvider, Type, Type)
Registers a singleton lifecycled type for a service
Declaration
public static IRegisteredService AddSingleton(this IServiceConfigurationProvider services, Type serviceType, Type implementationType)
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Type | serviceType | The service type |
System.Type | implementationType | The implementation type |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
AddSingleton<TService>(IServiceConfigurationProvider)
Registers a singleton lifecycled concrete type as a service
Declaration
public static IRegisteredService AddSingleton<TService>(this IServiceConfigurationProvider services)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService |
AddSingleton<TService>(IServiceConfigurationProvider, TService)
Registers a singleton lifecycled instance as a service
Declaration
public static IRegisteredService AddSingleton<TService>(this IServiceConfigurationProvider services, TService implementationInstance)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
TService | implementationInstance | The singleton instance |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService |
AddSingleton<TService>(IServiceConfigurationProvider, Func<IServiceLocator, TService>)
Registers a singleton lifecycled factory as a service
Declaration
public static IRegisteredService AddSingleton<TService>(this IServiceConfigurationProvider services, Func<IServiceLocator, TService> implementationFactory)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Func<IServiceLocator, TService> | implementationFactory | The factory used to create the singleton instance |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService |
AddSingleton<TService, TImplementation>(IServiceConfigurationProvider)
Registers a singleton lifecycled type for a service
Declaration
public static IRegisteredService AddSingleton<TService, TImplementation>(this IServiceConfigurationProvider services)
where TService : class where TImplementation : class, TService
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService | |
TImplementation |
AddSingleton<TService, TImplementation>(IServiceConfigurationProvider, Func<IServiceLocator, TImplementation>)
Registers a singleton lifecycled factory as a service
Declaration
public static IRegisteredService AddSingleton<TService, TImplementation>(this IServiceConfigurationProvider services, Func<IServiceLocator, TImplementation> implementationFactory)
where TService : class where TImplementation : class, TService
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Func<IServiceLocator, TImplementation> | implementationFactory | The factory used to create the singleton instance |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService | |
TImplementation |
AddTransient(IServiceConfigurationProvider, Type)
Registers a transient lifecycled type as a concrete service
Declaration
public static IRegisteredService AddTransient(this IServiceConfigurationProvider services, Type serviceType)
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Type | serviceType | The service type |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
AddTransient(IServiceConfigurationProvider, Type, Func<IServiceLocator, Object>)
Registers a transient lifecycled implementation factory for a service
Declaration
public static IRegisteredService AddTransient(this IServiceConfigurationProvider services, Type serviceType, Func<IServiceLocator, object> implementationFactory)
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Type | serviceType | The service type |
System.Func<IServiceLocator, System.Object> | implementationFactory | The implementation factory |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
AddTransient(IServiceConfigurationProvider, Type, Type)
Registers a transient lifecycled implementation for a service
Declaration
public static IRegisteredService AddTransient(this IServiceConfigurationProvider services, Type serviceType, Type implementationType)
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Type | serviceType | The service type |
System.Type | implementationType | The implementation type |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
AddTransient<TService>(IServiceConfigurationProvider)
Registers a transient lifecycled type as a concrete service
Declaration
public static IRegisteredService AddTransient<TService>(this IServiceConfigurationProvider services)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService |
AddTransient<TService>(IServiceConfigurationProvider, Func<IServiceLocator, TService>)
Registers a transient lifecycled factory for a service
Declaration
public static IRegisteredService AddTransient<TService>(this IServiceConfigurationProvider services, Func<IServiceLocator, TService> implementationFactory)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Func<IServiceLocator, TService> | implementationFactory | The factory method to create instances |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService |
AddTransient<TService, TImplementation>(IServiceConfigurationProvider)
Registers a transient lifecycled implementation for a service
Declaration
public static IRegisteredService AddTransient<TService, TImplementation>(this IServiceConfigurationProvider services)
where TService : class where TImplementation : class, TService
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService | |
TImplementation |
AddTransient<TService, TImplementation>(IServiceConfigurationProvider, Func<IServiceLocator, TImplementation>)
Registers a transient lifecycled factory for a service
Declaration
public static IRegisteredService AddTransient<TService, TImplementation>(this IServiceConfigurationProvider services, Func<IServiceLocator, TImplementation> implementationFactory)
where TService : class where TImplementation : class, TService
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Func<IServiceLocator, TImplementation> | implementationFactory | The factory method to create instances |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService | |
TImplementation |
Configure<TService>(IServiceConfigurationProvider, Action<TService>)
Used to configure a registered service before it's returned. Will be applied to all registered services in container of the provided type.
Declaration
public static IServiceConfigurationProvider Configure<TService>(this IServiceConfigurationProvider services, Action<TService> configure)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Action<TService> | configure | The method used to configure the service. |
Returns
Type | Description |
---|---|
IServiceConfigurationProvider | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService | The existing service that is configured |
Forward<T1, T2>(IServiceConfigurationProvider)
Register T2
as a service where actual instance is delegated to T1
Declaration
public static IRegisteredService Forward<T1, T2>(this IServiceConfigurationProvider services)
where T1 : class where T2 : class
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
Returns
Type | Description |
---|---|
IRegisteredService | The service configuration provider |
Type Parameters
Name | Description |
---|---|
T1 | An existing service |
T2 | An additional service |
Intercept<TService>(IServiceConfigurationProvider, Func<IServiceLocator, TService, TService>)
Used to intercept a registered service. Will replace all registered services in container. The interceptor factory will have access to the previous registered service.
Declaration
public static IServiceConfigurationProvider Intercept<TService>(this IServiceConfigurationProvider services, Func<IServiceLocator, TService, TService> interceptorFactory)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Func<IServiceLocator, TService, TService> | interceptorFactory | The factory that will be called to create the interceptor. The factory have access to the previous registered service. |
Returns
Type | Description |
---|---|
IServiceConfigurationProvider | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService | The existing service that is intercepted |
RegisterServiceAccessorDelegates(IServiceConfigurationProvider, Type)
Declaration
public static void RegisterServiceAccessorDelegates(IServiceConfigurationProvider registry, Type serviceType)
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | registry | |
System.Type | serviceType |
RemoveAll<TService>(IServiceConfigurationProvider)
Removes all previous registrations for the service.
Declaration
public static IServiceConfigurationProvider RemoveAll<TService>(this IServiceConfigurationProvider services)
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
Returns
Type | Description |
---|---|
IServiceConfigurationProvider | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService | The service to remove configurations for |
TryAdd<TService>(IServiceConfigurationProvider, ServiceInstanceScope)
Registers a concrete service if not already registered.
Declaration
public static IServiceConfigurationProvider TryAdd<TService>(this IServiceConfigurationProvider services, ServiceInstanceScope serviceInstanceScope)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
ServiceInstanceScope | serviceInstanceScope | The service scope |
Returns
Type | Description |
---|---|
IServiceConfigurationProvider | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService | The service type |
TryAdd<TService>(IServiceConfigurationProvider, Func<IServiceLocator, TService>)
Registers the service if not already registered.
Declaration
public static IServiceConfigurationProvider TryAdd<TService>(this IServiceConfigurationProvider services, Func<IServiceLocator, TService> implementationFactory)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Func<IServiceLocator, TService> | implementationFactory | The implementation factory |
Returns
Type | Description |
---|---|
IServiceConfigurationProvider | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService | The service type |
TryAdd<TService>(IServiceConfigurationProvider, Func<IServiceLocator, TService>, ServiceInstanceScope)
Registers the service if not already registered.
Declaration
public static IServiceConfigurationProvider TryAdd<TService>(this IServiceConfigurationProvider services, Func<IServiceLocator, TService> implementationFactory, ServiceInstanceScope serviceInstanceScope)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
System.Func<IServiceLocator, TService> | implementationFactory | The implementation factory |
ServiceInstanceScope | serviceInstanceScope | The service scope |
Returns
Type | Description |
---|---|
IServiceConfigurationProvider | The service configuration provider |
Type Parameters
Name | Description |
---|---|
TService | The service type |
TryAdd<TService, TImplementation>(IServiceConfigurationProvider, ServiceInstanceScope)
Registers the service if not already registered.
Declaration
public static IServiceConfigurationProvider TryAdd<TService, TImplementation>(this IServiceConfigurationProvider services, ServiceInstanceScope serviceInstanceScope)
where TService : class where TImplementation : class, TService
Parameters
Type | Name | Description |
---|---|---|
IServiceConfigurationProvider | services | The service provider that is extended |
ServiceInstanceScope | serviceInstanceScope | The service instance scope |
Returns
Type | Description |
---|---|
IServiceConfigurationProvider |
Type Parameters
Name | Description |
---|---|
TService | The service type |
TImplementation | The implementation type |