Microsoft.Extensions.DependencyInjection.Abstractions by Microsoft

<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0-rc.2.21480.5" />

 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.