MY TESTED ASP.NET CORE MVC DOCS
  • Tutorial
  • Testing Guide
  • API Reference
  • Troubleshoot
  • About
  • API Reference
  • MyTested.AspNetCore.Mvc
  • ServiceCollectionAbstractionsExtensions
Show / Hide Table of Contents
  • Common Classes & Extensions
    • ActionAttributesTestBuilderViewFeaturesExtensions
    • AuthenticationScheme
    • BadRequestTestBuilderDataAnnotationsExtensions
    • BadRequestTestBuilderExtensions
    • BaseShouldReturnTestBuilderExtensions
    • BaseTestBuilderWithResponseModelExtensions
    • ComponentBuilderAuthenticationExtensions
    • ComponentBuilderCachingExtensions
    • ComponentBuilderDependencyInjectionExtensions
    • ComponentBuilderEntityFrameworkCoreExtensions
    • ComponentBuilderHttpExtensions
    • ComponentBuilderOptionsExtensions
    • ComponentBuilderRoutingExtensions
    • ComponentBuilderSessionExtensions
    • ComponentBuilderTempDataExtensions
    • ComponentShouldHaveTestBuilderCachingExtensions
    • ComponentShouldHaveTestBuilderEntityFrameworkCoreExtensions
    • ComponentShouldHaveTestBuilderHttpExtensions
    • ComponentShouldHaveTestBuilderModelStateExtensions
    • ComponentShouldHaveTestBuilderSessionExtensions
    • ComponentShouldHaveTestBuilderTempDataExtensions
    • ComponentShouldHaveTestBuilderViewBagExtensions
    • ComponentShouldHaveTestBuilderViewDataExtensions
    • ContentType
    • ControllerBuilderDataAnnotationsExtensions
    • CreatedTestBuilderExtensions
    • From
    • HttpHeader
    • HttpMethod
    • HttpRequestBuilderAuthenticationExtensions
    • HttpRequestBuilderViewFeaturesExtensions
    • HttpScheme
    • HttpStatusCode
    • LocalRedirectTestBuilderExtensions
    • ModelErrorDetailsTestBuilderViewFeaturesExtensions
    • ModelErrorTestBuilderViewFeaturesExtensions
    • MyApplication
    • MyController<TController>
    • MyMvc
    • MyRouting
    • MyViewComponent<TViewComponent>
    • RedirectTestBuilderExtensions
    • ResolvedRouteTestBuilderDataAnnotationsExtensions
    • ServiceCollectionAbstractionsExtensions
    • ServiceCollectionCachingExtensions
    • ServiceCollectionControllersExtensions
    • ServiceCollectionCoreExtensions
    • ServiceCollectionEntityFrameworkCoreExtensions
    • ServiceCollectionExtensions
    • ServiceCollectionHttpExtensions
    • ServiceCollectionOptionsExtensions
    • ServiceCollectionRoutingExtensions
    • ServiceCollectionSessionExtensions
    • ServiceCollectionTempDataExtensions
    • ServiceCollectionUniverseExtensions
    • ServiceCollectionViewComponentsExtensions
    • ServiceCollectionViewFeaturesExtensions
    • ShouldReturnTestBuilderExtensions
    • ShouldReturnTestBuilderJsonResultExtensions
    • ShouldReturnTestBuilderPartialViewResultExtensions
    • ShouldReturnTestBuilderViewComponentResultExtensions
    • ShouldReturnTestBuilderViewResultExtensions
    • ViewComponentShouldReturnTestBuilderExtensions
    • With
  • ActionResults.BadRequest
    • IBadRequestErrorMessageTestBuilder
    • IBadRequestTestBuilder
  • ActionResults.Challenge
    • IChallengeTestBuilder
  • ActionResults.Content
    • IContentTestBuilder
  • ActionResults.Created
    • ICreatedTestBuilder
  • ActionResults.File
    • IFileTestBuilder
    • IPhysicalFileTestBuilder
  • ActionResults.Forbid
    • IForbidTestBuilder
  • ActionResults.Json
    • IJsonSerializerSettingsTestBuilder
    • IJsonTestBuilder
  • ActionResults.LocalRedirect
    • ILocalRedirectTestBuilder
  • ActionResults.NotFound
    • INotFoundTestBuilder
  • ActionResults.Object
    • IObjectTestBuilder
  • ActionResults.Ok
    • IOkTestBuilder
  • ActionResults.Redirect
    • IRedirectTestBuilder
  • ActionResults.StatusCode
    • IStatusCodeTestBuilder
  • ActionResults.View
    • IViewComponentTestBuilder
    • IViewTestBuilder
  • Actions
    • IActionResultTestBuilder<TActionResult>
    • IShouldHaveTestBuilder<TActionResult>
    • IShouldReturnTestBuilder<TActionResult>
    • IVoidActionResultTestBuilder
  • Application
    • IApplicationConfigurationBuilder
  • Attributes
    • IActionAttributesTestBuilder
    • IBaseAttributesTestBuilder<TAttributesTestBuilder>
    • IControllerActionAttributesTestBuilder<TAttributesTestBuilder>
    • IControllerAttributesTestBuilder
    • IViewComponentAttributesTestBuilder
  • Authentication
    • IAuthenticationPropertiesTestBuilder
    • IClaimsIdentityBuilder
    • IClaimsPrincipalBuilder
  • Base
    • IBaseTestBuilder
    • IBaseTestBuilderWithAction
    • IBaseTestBuilderWithActionResult<TActionResult>
    • IBaseTestBuilderWithComponent
    • IBaseTestBuilderWithComponentBuilder<TBuilder>
    • IBaseTestBuilderWithComponentShouldHaveTestBuilder<TBuilder>
    • IBaseTestBuilderWithController
    • IBaseTestBuilderWithInvokedAction
    • IBaseTestBuilderWithModel<TModel>
    • IBaseTestBuilderWithModelError
    • IBaseTestBuilderWithResponseModel
    • IBaseTestBuilderWithViewComponent
    • IBaseTestBuilderWithViewComponentInvocation
    • IBaseTestBuilderWithViewComponentResult<TInvocationResult>
  • CaughtExceptions
    • IAggregateExceptionTestBuilder
    • IBaseExceptionTestBuilder
    • IExceptionMessageTestBuilder
    • IExceptionTestBuilder
    • IShouldThrowTestBuilder
  • Controllers
    • IControllerBuilder<TController>
    • IControllerTestBuilder
  • Data
    • IDataProviderEntryDetailsTestBuilder<TValue>
    • IDataProviderEntryKeyTestBuilder
    • IDataProviderEntryTestBuilder
    • IDbContextBuilder
    • IDbContextTestBuilder
    • IMemoryCacheBuilder
    • IMemoryCacheEntryBuilder
    • IMemoryCacheEntryDetailsTestBuilder<TValue>
    • IMemoryCacheEntryKeyBuilder
    • IMemoryCacheEntryKeyTestBuilder
    • IMemoryCacheEntryTestBuilder
    • IMemoryCacheTestBuilder
    • ISessionBuilder
    • ISessionTestBuilder
    • ITempDataBuilder
    • ITempDataTestBuilder
    • IViewBagTestBuilder
    • IViewDataTestBuilder
  • Http
    • IHttpRequestBuilder
    • IHttpResponseTestBuilder
    • IResponseCookieTestBuilder
  • Invocations
    • IBaseShouldReturnTestBuilder
    • IBaseShouldReturnTestBuilder<TInvocationResult, TBuilder>
    • IBaseShouldReturnTestBuilder<TInvocationResult>
    • IViewComponentResultTestBuilder<TInvocationResult>
    • IViewComponentShouldHaveTestBuilder<TInvocationResult>
    • IViewComponentShouldReturnTestBuilder<TInvocationResult>
  • Models
    • IModelDetailsTestBuilder<TModel>
    • IModelErrorDetailsTestBuilder
    • IModelErrorDetailsTestBuilder<TModel>
    • IModelErrorTestBuilder
    • IModelErrorTestBuilder<TModel>
    • IModelStateTestBuilder
  • Options
    • IOptionsBuilder
  • Routing
    • IResolvedRouteTestBuilder
    • IRouteTestBuilder
    • IShouldMapTestBuilder
  • Services
    • IServicesBuilder
  • Uri
    • IUriBuilder
    • IUriTestBuilder
  • ViewComponentResults
    • IViewTestBuilder
  • ViewComponents
    • IViewComponentBuilder<TViewComponent>
    • IViewComponentTestBuilder

Class ServiceCollectionAbstractionsExtensions

Provides useful IServiceCollection extensions for testing purposes.

Inheritance
System.Object
ServiceCollectionAbstractionsExtensions
Namespace:MyTested.AspNetCore.Mvc
Assembly:MyTested.AspNetCore.Mvc.Abstractions.dll
Syntax
public static class ServiceCollectionAbstractionsExtensions

Methods

| Improve this Doc View Source

AddCoreTesting(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.
| Improve this Doc View Source

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.
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.
| Improve this Doc View Source

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.
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.
| Improve this Doc View Source

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.
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.
| Improve this Doc View Source

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.
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.
| Improve this Doc View Source

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.
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.
| Improve this Doc View Source

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.
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.
| Improve this Doc View Source

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.
| Improve this Doc View Source

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.
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.
| Improve this Doc View Source

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.
  • Improve this Doc
  • View Source
In This Article
  • Methods
    • AddCoreTesting(IServiceCollection)
    • Remove(IServiceCollection, Type)
    • Remove(IServiceCollection, Type, Type)
    • Remove<TService>(IServiceCollection)
    • Remove<TService, TImplementation>(IServiceCollection)
    • RemoveScoped(IServiceCollection, Type)
    • RemoveScoped(IServiceCollection, Type, Type)
    • RemoveScoped<TService>(IServiceCollection)
    • RemoveScoped<TService, TImplementation>(IServiceCollection)
    • RemoveSingleton(IServiceCollection, Type)
    • RemoveSingleton(IServiceCollection, Type, Type)
    • RemoveSingleton<TService>(IServiceCollection)
    • RemoveSingleton<TService, TImplementation>(IServiceCollection)
    • RemoveTransient(IServiceCollection, Type)
    • RemoveTransient(IServiceCollection, Type, Type)
    • RemoveTransient<TService>(IServiceCollection)
    • RemoveTransient<TService, TImplementation>(IServiceCollection)
    • Replace(IServiceCollection, Type, Func<IServiceProvider, Object>, ServiceLifetime)
    • Replace(IServiceCollection, Type, Type, ServiceLifetime)
    • Replace<TService>(IServiceCollection, Func<IServiceProvider, Object>, ServiceLifetime)
    • Replace<TService, TImplementation>(IServiceCollection, ServiceLifetime)
    • ReplaceEnumerable(IServiceCollection, ServiceDescriptor)
    • ReplaceEnumerable(IServiceCollection, IEnumerable<ServiceDescriptor>)
    • ReplaceLifetime(IServiceCollection, Type, ServiceLifetime)
    • ReplaceLifetime<TService>(IServiceCollection, ServiceLifetime)
    • ReplaceScoped(IServiceCollection, Type, Func<IServiceProvider, Object>)
    • ReplaceScoped(IServiceCollection, Type, Type)
    • ReplaceScoped<TService>(IServiceCollection, Func<IServiceProvider, Object>)
    • ReplaceScoped<TService, TImplementation>(IServiceCollection)
    • ReplaceSingleton(IServiceCollection, Type, Func<IServiceProvider, Object>)
    • ReplaceSingleton(IServiceCollection, Type, Object)
    • ReplaceSingleton(IServiceCollection, Type, Type)
    • ReplaceSingleton<TService>(IServiceCollection, Func<IServiceProvider, Object>)
    • ReplaceSingleton<TService>(IServiceCollection, Object)
    • ReplaceSingleton<TService, TImplementation>(IServiceCollection)
    • ReplaceTransient(IServiceCollection, Type, Func<IServiceProvider, Object>)
    • ReplaceTransient(IServiceCollection, Type, Type)
    • ReplaceTransient<TService>(IServiceCollection, Func<IServiceProvider, Object>)
    • ReplaceTransient<TService, TImplementation>(IServiceCollection)
Back to top Copyright © 2015-2016 MyTestedASP.NET. All Rights Reserved. Generated by DocFX