Table of Contents

Class ServiceCollectionExtensions

Namespace
Mokkit.Containers.Microsoft.Extensions.DependencyInjection
Assembly
Mokkit.Containers.Microsoft.Extensions.DependencyInjection.dll

Provides extension methods for Microsoft.Extensions.DependencyInjection.IServiceCollection to enable stage-based service resolution. These extensions allow services to be resolved from the test stage context rather than the DI container.

public static class ServiceCollectionExtensions

Inheritance

Inherited Members

Methods

ResolveFromStage<T>(IServiceCollection, ServiceLifetime)

Registers a service of type T to be resolved from the test stage context. This method allows services to be resolved from the test host bag rather than the DI container.

public static IServiceCollection ResolveFromStage<T>(this IServiceCollection services, ServiceLifetime lifetime = ServiceLifetime.Transient)

Parameters

services IServiceCollection

The service collection to add the registration to.

lifetime ServiceLifetime

The service lifetime for the registration. Defaults to Microsoft.Extensions.DependencyInjection.ServiceLifetime.Transient.

Returns

IServiceCollection

The service collection for method chaining.

Type Parameters

T

The type of service to register for stage resolution.

ResolveFromStage(IServiceCollection, Type, ServiceLifetime)

Registers a service of the specified type to be resolved from the test stage context. This method creates a service descriptor that uses Mokkit.Containers.IStageResolve to resolve services from the test host bag.

public static IServiceCollection ResolveFromStage(this IServiceCollection services, Type serviceType, ServiceLifetime lifetime = ServiceLifetime.Transient)

Parameters

services IServiceCollection

The service collection to add the registration to.

serviceType Type

The type of service to register for stage resolution.

lifetime ServiceLifetime

The service lifetime for the registration. Defaults to Microsoft.Extensions.DependencyInjection.ServiceLifetime.Transient.

Returns

IServiceCollection

The service collection for method chaining.

Exceptions

InvalidOperationException

Thrown when the service cannot be resolved from the stage context.