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

Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions

public static class ServiceProviderServiceExtensions
Extension methods for getting services from an IServiceProvider.
namespace Microsoft.Extensions.DependencyInjection { public static class ServiceProviderServiceExtensions { public static T GetService<T>(this IServiceProvider provider); public static object GetRequiredService(this IServiceProvider provider, Type serviceType); public static T GetRequiredService<T>(this IServiceProvider provider); public static IEnumerable<T> GetServices<[System.Runtime.CompilerServices.Nullable(2)] T>(this IServiceProvider provider); public static IEnumerable<object> GetServices(this IServiceProvider provider, Type serviceType); public static IServiceScope CreateScope(this IServiceProvider provider); public static AsyncServiceScope CreateAsyncScope(this IServiceProvider provider); public static AsyncServiceScope CreateAsyncScope(this IServiceScopeFactory serviceScopeFactory); } }