Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class Microsoft.​Extensions.​DependencyInjection.​ServiceProviderServiceExtensions

Assembly: Microsoft.Extensions.DependencyInjection.Abstractions

Inheritance: object → ServiceProviderServiceExtensions

Extension methods for getting services from an <see cref="T:System.IServiceProvider" /> .

Methods

public static AsyncServiceScope
CreateAsyncScope​(IServiceScopeFactory serviceScopeFactory)
Creates a new <see cref="T:Microsoft.Extensions.DependencyInjection.AsyncServiceScope" /> that can be used to resolve scoped services.
Returns An <see cref="T:Microsoft.Extensions.DependencyInjection.AsyncServiceScope" /> that can be used to resolve scoped services.
serviceScopeFactory The <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceScopeFactory" /> to create the scope from.
public static AsyncServiceScope
CreateAsyncScope​(System.​IServiceProvider provider)
Creates a new <see cref="T:Microsoft.Extensions.DependencyInjection.AsyncServiceScope" /> that can be used to resolve scoped services.
Returns An <see cref="T:Microsoft.Extensions.DependencyInjection.AsyncServiceScope" /> that can be used to resolve scoped services.
provider The <see cref="T:System.IServiceProvider" /> to create the scope from.
public static IServiceScope
CreateScope​(System.​IServiceProvider provider)
Creates a new <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceScope" /> that can be used to resolve scoped services.
Returns A <see cref="T:Microsoft.Extensions.DependencyInjection.IServiceScope" /> that can be used to resolve scoped services.
provider The <see cref="T:System.IServiceProvider" /> to create the scope from.
public static object
GetRequiredService​(System.​IServiceProvider provider, System.​Type serviceType)
Get service of type <paramref name="serviceType" /> from the <see cref="T:System.IServiceProvider" /> .
Returns A service object of type <paramref name="serviceType" /> .
provider The <see cref="T:System.IServiceProvider" /> to retrieve the service object from.
serviceType An object that specifies the type of service object to get.
public static T
GetRequiredService​(System.​IServiceProvider provider)
Get service of type <typeparamref name="T" /> from the <see cref="T:System.IServiceProvider" /> .
Returns A service object of type <typeparamref name="T" /> .
provider The <see cref="T:System.IServiceProvider" /> to retrieve the service object from.
GetServices​(System.​IServiceProvider provider, System.​Type serviceType)
Get an enumeration of services of type <paramref name="serviceType" /> from the <see cref="T:System.IServiceProvider" /> .
Returns An enumeration of services of type <paramref name="serviceType" /> .
provider The <see cref="T:System.IServiceProvider" /> to retrieve the services from.
serviceType An object that specifies the type of service object to get.
GetServices​(System.​IServiceProvider provider)
Get an enumeration of services of type <typeparamref name="T" /> from the <see cref="T:System.IServiceProvider" /> .
Returns An enumeration of services of type <typeparamref name="T" /> .
provider The <see cref="T:System.IServiceProvider" /> to retrieve the services from.
public static T
GetService​(System.​IServiceProvider provider)
Get service of type <typeparamref name="T" /> from the <see cref="T:System.IServiceProvider" /> .
Returns A service object of type <typeparamref name="T" /> or null if there is no such service.
provider The <see cref="T:System.IServiceProvider" /> to retrieve the service object from.
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object