Class ServiceProviderServiceExtensions
Extension methods for getting services from an IServiceProvider.
Inherited Members
Namespace: nanoFramework.DependencyInjection
Assembly: nanoFramework.DependencyInjection.dll
Syntax
public static class ServiceProviderServiceExtensions
Methods
CreateScope(IServiceProvider)
Creates a new ServiceScope that can be used to resolve scoped services.
Declaration
public static IServiceScope CreateScope(this IServiceProvider provider)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceProvider | provider | The IServiceProvider to create the scope from. |
Returns
| Type | Description |
|---|---|
| IServiceScope | An ServiceScope that can be used to resolve scoped services. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
GetRequiredService(IServiceProvider, Type)
Get service of type serviceType from the IServiceProvider.
Declaration
public static object GetRequiredService(this IServiceProvider provider, Type serviceType)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceProvider | provider | The IServiceProvider to retrieve the service object from. |
| Type | serviceType | An object that specifies the type of service object to get. |
Returns
| Type | Description |
|---|---|
| object | A service object of type |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | There is no service of type |
| ArgumentNullException |
|
GetServices(IServiceProvider, Type)
Get an enumeration of services of type serviceType from the IServiceProvider.
Declaration
public static object[] GetServices(this IServiceProvider provider, Type serviceType)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceProvider | provider | The IServiceProvider to retrieve the services from. |
| Type | serviceType | An object that specifies the type of service object to get. |
Returns
| Type | Description |
|---|---|
| object[] | An array of services of type |
GetServices(IServiceProvider, Type[])
Get an enumeration of services of type serviceType from the IServiceProvider.
Declaration
public static object[] GetServices(this IServiceProvider provider, Type[] serviceType)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceProvider | provider | The IServiceProvider to retrieve the services from. |
| Type[] | serviceType | An array of |
Returns
| Type | Description |
|---|---|
| object[] | An array of services of type |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | 'provider' or 'serviceType' can't be null. |