Interface IFactoryInjector
Factory Injector should be used in cases where constructors are dynamically invoked, and require the IServiceProvider in order to satisfy the arguments. Where you see ctor.Invoke(new object{ ... }), this might be a candidate for IFactoryInjector.
Namespace: LemonEdge.API.Core.Reflection
Assembly: LemonEdge.API.dll
Syntax
public interface IFactoryInjector
Methods
Create(Type, params object[])
Create(Type, params object[]) where the Type parameters are inferred from the args.
Declaration
object Create(Type returnType, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
Type | returnType | The type being instantiated. |
object[] | args | The arguments to the factory method must uniquely satisfy a single constructor. |
Returns
Type | Description |
---|---|
object | The instantiated type. |
CreateInstance(Type, params object[])
Create(Type, params object[]) where the Type parameters are inferred from the args.
Does not use a factory, and thus can create an instance when there are multiple constructors, but only one that matches given the parameters
Declaration
object CreateInstance(Type returnType, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
Type | returnType | The type being instantiated. |
object[] | args | The arguments to the factory method must uniquely satisfy a single constructor. |
Returns
Type | Description |
---|---|
object | The instantiated type. |
CreateInstance<T>(params object[])
Create<T>(params object[]) where the Type parameters are inferred from the args.
Does not use a factory, and thus can create an instance when there are multiple constructors, but only one that matches given the parameters
Declaration
T CreateInstance<T>(params object[] args) where T : class
Parameters
Type | Name | Description |
---|---|---|
object[] | args | The arguments to the factory method must uniquely satisfy a single constructor. |
Returns
Type | Description |
---|---|
T | The instantiated type. |
Type Parameters
Name | Description |
---|---|
T |
Create<T>(params object[])
Create<T>(params object[]) where the Type parameters are inferred from the args.
Declaration
T Create<T>(params object[] args) where T : class
Parameters
Type | Name | Description |
---|---|---|
object[] | args | The arguments to the factory method must uniquely satisfy a single constructor. |
Returns
Type | Description |
---|---|
T | The instantiated type. |
Type Parameters
Name | Description |
---|---|
T |