Table of Contents

Class ServiceProviderServiceExtensions

Namespace
Microsoft.Extensions.DependencyInjection
Assembly
nanoFramework.DependencyInjection.dll

Extension methods for getting services from an IServiceProvider.

public static class ServiceProviderServiceExtensions
Inheritance
ServiceProviderServiceExtensions
Inherited Members

Methods

CreateScope(IServiceProvider)

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

public static IServiceScope CreateScope(this IServiceProvider provider)

Parameters

provider IServiceProvider

The IServiceProvider to create the scope from.

Returns

IServiceScope

An ServiceScope that can be used to resolve scoped services.

Exceptions

ArgumentNullException

providercan't be null.

GetRequiredService(IServiceProvider, Type)

Get service of type serviceType from the IServiceProvider.

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

Parameters

provider IServiceProvider

The IServiceProvider to retrieve the service object from.

serviceType Type

An object that specifies the type of service object to get.

Returns

object

A service object of type serviceType.

Exceptions

InvalidOperationException

There is no service of type serviceType.

ArgumentNullException

provider or serviceType can't be null.

GetServices(IServiceProvider, Type)

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

public static object[] GetServices(this IServiceProvider provider, Type serviceType)

Parameters

provider IServiceProvider

The IServiceProvider to retrieve the services from.

serviceType Type

An object that specifies the type of service object to get.

Returns

object[]

An array of services of type serviceType.

GetServices(IServiceProvider, Type[])

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

public static object[] GetServices(this IServiceProvider provider, Type[] serviceType)

Parameters

provider IServiceProvider

The IServiceProvider to retrieve the services from.

serviceType Type[]

An array of serviceType object that specifies the type of service object to get.

Returns

object[]

An array of services of type serviceType.

Exceptions

ArgumentNullException

'provider' or 'serviceType' can't be null.