Table of Contents

Class ServiceProviderExtensions

Namespace
Codebelt.Extensions.Xunit.Hosting
Assembly
Codebelt.Extensions.Xunit.Hosting.dll

Provides extension methods for the System.IServiceProvider interface.

public static class ServiceProviderExtensions
Inheritance
Object
ServiceProviderExtensions

Methods

GetRequiredScopedService<T>(IServiceProvider)

Gets a required scoped service of type T from the System.IServiceProvider.

public static T GetRequiredScopedService<T>(this IServiceProvider provider)

Parameters

provider IServiceProvider

The System.IServiceProvider to retrieve the service from.

Returns

T

The required service of type T.

Type Parameters

T

The type of the service to retrieve.

Exceptions

System.InvalidOperationException

There is no service of type T.