Class ServiceCollectionExtensions
Inheritance
Namespace: Umbraco.Extensions
Assembly: Umbraco.Core.dll
Syntax
public static class ServiceCollectionExtensions
Methods
View SourceAddMultipleUnique<TService1, TService2, TImplementing>(IServiceCollection)
Adds services of types TService1
& TService2
with a shared
implementation type of TImplementing
to the specified
Declaration
public static void AddMultipleUnique<TService1, TService2, TImplementing>(this IServiceCollection services)
where TService1 : class where TService2 : class where TImplementing : class, TService1, TService2
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services |
Type Parameters
Name | Description |
---|---|
TService1 | |
TService2 | |
TImplementing |
Remarks
Removes all previous registrations for the types TService1
&
TService2
.
AddMultipleUnique<TService1, TService2, TImplementing>(IServiceCollection, ServiceLifetime)
Adds services of types TService1
& TService2
with a shared implementation type of TImplementing
to the specified
Declaration
public static void AddMultipleUnique<TService1, TService2, TImplementing>(this IServiceCollection services, ServiceLifetime lifetime)
where TService1 : class where TService2 : class where TImplementing : class, TService1, TService2
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | |
ServiceLifetime | lifetime |
Type Parameters
Name | Description |
---|---|
TService1 | |
TService2 | |
TImplementing |
Remarks
Removes all previous registrations for the types TService1
& TService2
.
AddUnique(IServiceCollection, Type, Object)
Adds a singleton service of the type specified by serviceType
to the specified
Declaration
public static void AddUnique(this IServiceCollection services, Type serviceType, object instance)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | |
Type | serviceType | |
System.Object | instance |
Remarks
Removes all previous registrations for the type specified by serviceType
.
AddUnique<TService>(IServiceCollection, TService)
Adds a singleton service of type TService
to the specified
Declaration
public static void AddUnique<TService>(this IServiceCollection services, TService instance)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | |
TService | instance |
Type Parameters
Name | Description |
---|---|
TService |
Remarks
Removes all previous registrations for the type type TService
.
AddUnique<TService>(IServiceCollection, Func<IServiceProvider, TService>)
Adds a service of type TService
with an implementation factory method to the specified
Declaration
public static void AddUnique<TService>(this IServiceCollection services, Func<IServiceProvider, TService> factory)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | |
Func<IServiceProvider, TService> | factory |
Type Parameters
Name | Description |
---|---|
TService |
Remarks
Removes all previous registrations for the type TService
.
AddUnique<TService>(IServiceCollection, Func<IServiceProvider, TService>, ServiceLifetime)
Adds a service of type TService
with an implementation factory method to the specified
Declaration
public static void AddUnique<TService>(this IServiceCollection services, Func<IServiceProvider, TService> factory, ServiceLifetime lifetime)
where TService : class
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | |
Func<IServiceProvider, TService> | factory | |
ServiceLifetime | lifetime |
Type Parameters
Name | Description |
---|---|
TService |
Remarks
Removes all previous registrations for the type TService
.
AddUnique<TService, TImplementing>(IServiceCollection)
Adds a service of type TService
with an implementation type of
TImplementing
to the specified
Declaration
public static void AddUnique<TService, TImplementing>(this IServiceCollection services)
where TService : class where TImplementing : class, TService
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services |
Type Parameters
Name | Description |
---|---|
TService | |
TImplementing |
Remarks
Removes all previous registrations for the type TService
.
AddUnique<TService, TImplementing>(IServiceCollection, ServiceLifetime)
Adds a service of type TService
with an implementation type of
TImplementing
to the specified
Declaration
public static void AddUnique<TService, TImplementing>(this IServiceCollection services, ServiceLifetime lifetime)
where TService : class where TImplementing : class, TService
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services | |
ServiceLifetime | lifetime |
Type Parameters
Name | Description |
---|---|
TService | |
TImplementing |
Remarks
Removes all previous registrations for the type TService
.