<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.6" />

ServiceProviderServiceExtensions

public static class ServiceProviderServiceExtensions
Extension methods for getting services from an IServiceProvider.

Creates a new AsyncServiceScope that can be used to resolve scoped services.

public static AsyncServiceScope CreateAsyncScope(this IServiceScopeFactory serviceScopeFactory)

Creates a new AsyncServiceScope that can be used to resolve scoped services.

public static IServiceScope CreateScope(this IServiceProvider provider)

Creates a new IServiceScope that can be used to resolve scoped services.

public static object GetRequiredService(this IServiceProvider provider, Type serviceType)

Get service of type serviceType from the IServiceProvider.

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

Get service of type T from the IServiceProvider.

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

Get service of type T from the IServiceProvider.

public static IEnumerable<T> GetServices<T>(this IServiceProvider provider)

Get an enumeration of services of type T from the IServiceProvider.

public static IEnumerable<object> GetServices(this IServiceProvider provider, Type serviceType)

Get an enumeration of services of type serviceType from the IServiceProvider.