Class ActivatorUtilities
Helper code for the various activator services.
Inherited Members
Namespace: nanoFramework.DependencyInjection
Assembly: nanoFramework.DependencyInjection.dll
Syntax
public static class ActivatorUtilities
Methods
CreateInstance(IServiceProvider, Type, params object[])
Instantiate a type with constructor arguments provided directly and/or from an IServiceProvider.
Declaration
public static object CreateInstance(IServiceProvider provider, Type instanceType, params object[] parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceProvider | provider | The service provider used to resolve dependencies. |
| Type | instanceType | The type to activate. |
| object[] | parameters | Constructor arguments not provided by the |
Returns
| Type | Description |
|---|---|
| object | An activated object of type |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | A suitable constructor for type |
GetServiceOrCreateInstance(IServiceProvider, Type, params object[])
Retrieve an instance of the given type from the service provider. If one is not found then instantiate it directly.
Declaration
public static object GetServiceOrCreateInstance(IServiceProvider provider, Type type, params object[] parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceProvider | provider | The service provider. |
| Type | type | The type of the service. |
| object[] | parameters | Constructor arguments not provided by the |
Returns
| Type | Description |
|---|---|
| object | The resolved service or created instance. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Unable to resolve a service while attempting to activate a constructor. |