Class ServiceCollectionAbstractionsExtensions
Provides useful IServiceCollection extensions for testing purposes.
Inheritance
Namespace:MyTested.AspNetCore.Mvc
Assembly:MyTested.AspNetCore.Mvc.Abstractions.dll
Syntax
public static class ServiceCollectionAbstractionsExtensions
Methods
| Improve this Doc View SourceAddCoreTesting(IServiceCollection)
Adds core MVC testing services.
Declaration
public static IServiceCollection AddCoreTesting(this IServiceCollection serviceCollection)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Remove(IServiceCollection, Type)
Removes а service from the IServiceCollection.
Declaration
public static IServiceCollection Remove(this IServiceCollection serviceCollection, Type service)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Type | service | Type of the service which will be removed. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Remove(IServiceCollection, Type, Type)
Removes a service from the IServiceCollection.
Declaration
public static IServiceCollection Remove(this IServiceCollection serviceCollection, Type service, Type implementationType)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Type | service | Type of the service which will be removed. |
System.Type | implementationType | Service implementation type which will be removed. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Remove<TService>(IServiceCollection)
Removes a service from the IServiceCollection.
Declaration
public static IServiceCollection Remove<TService>(this IServiceCollection serviceCollection)where TService : class
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Type Parameters
Name | Description |
---|---|
TService | Type of the service which will be removed. |
Remove<TService, TImplementation>(IServiceCollection)
Removes a service from the IServiceCollection.
Declaration
public static IServiceCollection Remove<TService, TImplementation>(this IServiceCollection serviceCollection)where TService : class where TImplementation : class, TService
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Type Parameters
Name | Description |
---|---|
TService | Type of the service which will be removed. |
TImplementation | Service implementation type which will be removed. |
RemoveScoped(IServiceCollection, Type)
Removes a scoped service from the IServiceCollection.
Declaration
public static IServiceCollection RemoveScoped(this IServiceCollection serviceCollection, Type service)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Type | service | Type of the service which will be removed. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
RemoveScoped(IServiceCollection, Type, Type)
Removes a scoped service from the IServiceCollection.
Declaration
public static IServiceCollection RemoveScoped(this IServiceCollection serviceCollection, Type service, Type implementationType)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Type | service | Type of the service which will be removed. |
System.Type | implementationType | Service implementation type which will be removed. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
RemoveScoped<TService>(IServiceCollection)
Removes a scoped service from the IServiceCollection.
Declaration
public static IServiceCollection RemoveScoped<TService>(this IServiceCollection serviceCollection)where TService : class
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Type Parameters
Name | Description |
---|---|
TService | Type of the service which will be removed. |
RemoveScoped<TService, TImplementation>(IServiceCollection)
Removes a scoped service from the IServiceCollection.
Declaration
public static IServiceCollection RemoveScoped<TService, TImplementation>(this IServiceCollection serviceCollection)where TService : class where TImplementation : class, TService
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Type Parameters
Name | Description |
---|---|
TService | Type of the service which will be removed. |
TImplementation | Service implementation type which will be removed. |
RemoveSingleton(IServiceCollection, Type)
Removes a singleton service from the IServiceCollection.
Declaration
public static IServiceCollection RemoveSingleton(this IServiceCollection serviceCollection, Type service)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Type | service | Type of the service which will be removed. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
RemoveSingleton(IServiceCollection, Type, Type)
Removes a singleton service from the IServiceCollection.
Declaration
public static IServiceCollection RemoveSingleton(this IServiceCollection serviceCollection, Type service, Type implementationType)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Type | service | Type of the service which will be removed. |
System.Type | implementationType | Service implementation type which will be removed. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
RemoveSingleton<TService>(IServiceCollection)
Removes a singleton service from the IServiceCollection.
Declaration
public static IServiceCollection RemoveSingleton<TService>(this IServiceCollection serviceCollection)where TService : class
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Type Parameters
Name | Description |
---|---|
TService | Type of the service which will be removed. |
RemoveSingleton<TService, TImplementation>(IServiceCollection)
Removes a singleton service from the IServiceCollection.
Declaration
public static IServiceCollection RemoveSingleton<TService, TImplementation>(this IServiceCollection serviceCollection)where TService : class where TImplementation : class, TService
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Type Parameters
Name | Description |
---|---|
TService | Type of the service which will be removed. |
TImplementation | Service implementation type which will be removed. |
RemoveTransient(IServiceCollection, Type)
Removes a transient service from the IServiceCollection.
Declaration
public static IServiceCollection RemoveTransient(this IServiceCollection serviceCollection, Type service)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Type | service | Type of the service which will be removed. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
RemoveTransient(IServiceCollection, Type, Type)
Removes a transient service from the IServiceCollection.
Declaration
public static IServiceCollection RemoveTransient(this IServiceCollection serviceCollection, Type service, Type implementationType)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Type | service | Type of the service which will be removed. |
System.Type | implementationType | Service implementation type which will be removed. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
RemoveTransient<TService>(IServiceCollection)
Removes a transient service from the IServiceCollection.
Declaration
public static IServiceCollection RemoveTransient<TService>(this IServiceCollection serviceCollection)where TService : class
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Type Parameters
Name | Description |
---|---|
TService | Type of the service which will be removed. |
RemoveTransient<TService, TImplementation>(IServiceCollection)
Removes a transient service from the IServiceCollection.
Declaration
public static IServiceCollection RemoveTransient<TService, TImplementation>(this IServiceCollection serviceCollection)where TService : class where TImplementation : class, TService
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Type Parameters
Name | Description |
---|---|
TService | Type of the service which will be removed. |
TImplementation | Service implementation type which will be removed. |
Replace(IServiceCollection, Type, Func<IServiceProvider, Object>, ServiceLifetime)
Replaces a service in the IServiceCollection.
Declaration
public static IServiceCollection Replace(this IServiceCollection serviceCollection, Type service, Func<IServiceProvider, object> implementationFactory, ServiceLifetime lifetime)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Type | service | Type of the service which will be replaced. |
System.Func<System.IServiceProvider, System.Object> | implementationFactory | Service implementation factory which will be used for replacement. |
Microsoft.Extensions.DependencyInjection.ServiceLifetime | lifetime | The ServiceLifetime which will be applied on the replaced service. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Replace(IServiceCollection, Type, Type, ServiceLifetime)
Replaces a service in the IServiceCollection.
Declaration
public static IServiceCollection Replace(this IServiceCollection serviceCollection, Type service, Type implementationType, ServiceLifetime lifetime)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Type | service | Type of the service which will be replaced. |
System.Type | implementationType | Service implementation type which will be used for replacement. |
Microsoft.Extensions.DependencyInjection.ServiceLifetime | lifetime | The ServiceLifetime which will be applied on the replaced service. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Replace<TService>(IServiceCollection, Func<IServiceProvider, Object>, ServiceLifetime)
Replaces a service in the IServiceCollection.
Declaration
public static IServiceCollection Replace<TService>(this IServiceCollection serviceCollection, Func<IServiceProvider, object> implementationFactory, ServiceLifetime lifetime)where TService : class
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Func<System.IServiceProvider, System.Object> | implementationFactory | Service implementation factory which will be used for replacement. |
Microsoft.Extensions.DependencyInjection.ServiceLifetime | lifetime | The ServiceLifetime which will be applied on the replaced service. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Type Parameters
Name | Description |
---|---|
TService | Type of the service which will be replaced. |
Replace<TService, TImplementation>(IServiceCollection, ServiceLifetime)
Replaces a service in the IServiceCollection.
Declaration
public static IServiceCollection Replace<TService, TImplementation>(this IServiceCollection serviceCollection, ServiceLifetime lifetime)where TService : class where TImplementation : class, TService
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
Microsoft.Extensions.DependencyInjection.ServiceLifetime | lifetime | The ServiceLifetime which will be applied on the replaced service. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Type Parameters
Name | Description |
---|---|
TService | Type of the service which will be replaced. |
TImplementation | Service implementation type which will be used for replacement. |
ReplaceEnumerable(IServiceCollection, ServiceDescriptor)
Replaces multiple services in the IServiceCollection.
Declaration
public static void ReplaceEnumerable(this IServiceCollection serviceCollection, ServiceDescriptor descriptor)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
Microsoft.Extensions.DependencyInjection.ServiceDescriptor | descriptor | ServiceDescriptor providing the services. |
ReplaceEnumerable(IServiceCollection, IEnumerable<ServiceDescriptor>)
Replaces multiple services in the IServiceCollection.
Declaration
public static void ReplaceEnumerable(this IServiceCollection serviceCollection, IEnumerable<ServiceDescriptor> descriptors)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Collections.Generic.IEnumerable<Microsoft.Extensions.DependencyInjection.ServiceDescriptor> | descriptors | ServiceDescriptor providing the services. |
ReplaceLifetime(IServiceCollection, Type, ServiceLifetime)
Replaces service lifetime in the IServiceCollection.
Declaration
public static IServiceCollection ReplaceLifetime(this IServiceCollection serviceCollection, Type service, ServiceLifetime lifetime)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Type | service | Type of the service which will be replaced. |
Microsoft.Extensions.DependencyInjection.ServiceLifetime | lifetime | The ServiceLifetime which will be applied on the replaced service. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
ReplaceLifetime<TService>(IServiceCollection, ServiceLifetime)
Replaces service lifetime in the IServiceCollection.
Declaration
public static IServiceCollection ReplaceLifetime<TService>(this IServiceCollection serviceCollection, ServiceLifetime lifetime)where TService : class
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
Microsoft.Extensions.DependencyInjection.ServiceLifetime | lifetime | The ServiceLifetime which will be applied on the replaced service. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Type Parameters
Name | Description |
---|---|
TService | Type of the service which will be replaced. |
ReplaceScoped(IServiceCollection, Type, Func<IServiceProvider, Object>)
Replaces a scoped service in the IServiceCollection.
Declaration
public static IServiceCollection ReplaceScoped(this IServiceCollection serviceCollection, Type service, Func<IServiceProvider, object> implementationFactory)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Type | service | Type of the service which will be replaced. |
System.Func<System.IServiceProvider, System.Object> | implementationFactory | Service implementation factory which will be used for replacement. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
ReplaceScoped(IServiceCollection, Type, Type)
Replaces a scoped service in the IServiceCollection.
Declaration
public static IServiceCollection ReplaceScoped(this IServiceCollection serviceCollection, Type service, Type implementationType)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Type | service | Type of the service which will be replaced. |
System.Type | implementationType | Service implementation type which will be used for replacement. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
ReplaceScoped<TService>(IServiceCollection, Func<IServiceProvider, Object>)
Replaces a scoped service in the IServiceCollection.
Declaration
public static IServiceCollection ReplaceScoped<TService>(this IServiceCollection serviceCollection, Func<IServiceProvider, object> implementationFactory)where TService : class
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Func<System.IServiceProvider, System.Object> | implementationFactory | Service implementation factory which will be used for replacement. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Type Parameters
Name | Description |
---|---|
TService | Type of the service which will be replaced. |
ReplaceScoped<TService, TImplementation>(IServiceCollection)
Replaces a scoped service in the IServiceCollection.
Declaration
public static IServiceCollection ReplaceScoped<TService, TImplementation>(this IServiceCollection serviceCollection)where TService : class where TImplementation : class, TService
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Type Parameters
Name | Description |
---|---|
TService | Type of the service which will be replaced. |
TImplementation | Service implementation type which will be used for replacement. |
ReplaceSingleton(IServiceCollection, Type, Func<IServiceProvider, Object>)
Replaces a singleton service in the IServiceCollection.
Declaration
public static IServiceCollection ReplaceSingleton(this IServiceCollection serviceCollection, Type service, Func<IServiceProvider, object> implementationFactory)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Type | service | Type of the service which will be replaced. |
System.Func<System.IServiceProvider, System.Object> | implementationFactory | Service implementation factory which will be used for replacement. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
ReplaceSingleton(IServiceCollection, Type, Object)
Replaces a singleton service in the IServiceCollection.
Declaration
public static IServiceCollection ReplaceSingleton(this IServiceCollection serviceCollection, Type service, object implementationInstance)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Type | service | Type of the service which will be replaced. |
System.Object | implementationInstance | Service implementation instance which will be used for replacement. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
ReplaceSingleton(IServiceCollection, Type, Type)
Replaces a singleton service in the IServiceCollection.
Declaration
public static IServiceCollection ReplaceSingleton(this IServiceCollection serviceCollection, Type service, Type implementationType)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Type | service | Type of the service which will be replaced. |
System.Type | implementationType | Service implementation type which will be used for replacement. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
ReplaceSingleton<TService>(IServiceCollection, Func<IServiceProvider, Object>)
Replaces a singleton service in the IServiceCollection.
Declaration
public static IServiceCollection ReplaceSingleton<TService>(this IServiceCollection serviceCollection, Func<IServiceProvider, object> implementationFactory)where TService : class
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Func<System.IServiceProvider, System.Object> | implementationFactory | Service implementation factory which will be used for replacement. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Type Parameters
Name | Description |
---|---|
TService | Type of the service which will be replaced. |
ReplaceSingleton<TService>(IServiceCollection, Object)
Replaces a singleton service in the IServiceCollection.
Declaration
public static IServiceCollection ReplaceSingleton<TService>(this IServiceCollection serviceCollection, object implementationInstance)where TService : class
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Object | implementationInstance | Service implementation instance which will be used for replacement. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Type Parameters
Name | Description |
---|---|
TService | Type of the service which will be replaced. |
ReplaceSingleton<TService, TImplementation>(IServiceCollection)
Replaces a singleton service in the IServiceCollection.
Declaration
public static IServiceCollection ReplaceSingleton<TService, TImplementation>(this IServiceCollection serviceCollection)where TService : class where TImplementation : class, TService
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Type Parameters
Name | Description |
---|---|
TService | Type of the service which will be replaced. |
TImplementation | Service implementation type which will be used for replacement. |
ReplaceTransient(IServiceCollection, Type, Func<IServiceProvider, Object>)
Replaces a transient service in the IServiceCollection.
Declaration
public static IServiceCollection ReplaceTransient(this IServiceCollection serviceCollection, Type service, Func<IServiceProvider, object> implementationFactory)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Type | service | Type of the service which will be replaced. |
System.Func<System.IServiceProvider, System.Object> | implementationFactory | Service implementation factory which will be used for replacement. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
ReplaceTransient(IServiceCollection, Type, Type)
Replaces a transient service in the IServiceCollection.
Declaration
public static IServiceCollection ReplaceTransient(this IServiceCollection serviceCollection, Type service, Type implementationType)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Type | service | Type of the service which will be replaced. |
System.Type | implementationType | Service implementation type which will be used for replacement. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
ReplaceTransient<TService>(IServiceCollection, Func<IServiceProvider, Object>)
Replaces a transient service in the IServiceCollection.
Declaration
public static IServiceCollection ReplaceTransient<TService>(this IServiceCollection serviceCollection, Func<IServiceProvider, object> implementationFactory)where TService : class
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
System.Func<System.IServiceProvider, System.Object> | implementationFactory | Service implementation factory which will be used for replacement. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Type Parameters
Name | Description |
---|---|
TService | Type of the service which will be replaced. |
ReplaceTransient<TService, TImplementation>(IServiceCollection)
Replaces a transient service in the IServiceCollection.
Declaration
public static IServiceCollection ReplaceTransient<TService, TImplementation>(this IServiceCollection serviceCollection)where TService : class where TImplementation : class, TService
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | serviceCollection | Instance of IServiceCollection type. |
Returns
Type | Description |
---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | The same IServiceCollection. |
Type Parameters
Name | Description |
---|---|
TService | Type of the service which will be replaced. |
TImplementation | Service implementation type which will be used for replacement. |