CreateInstance Method
CreateInstance<TService>(IDictionary<string, string>, params object[])
Creates a new instance of type TService
.
Declaration
public static TService CreateInstance<TService>(IDictionary<string, string> stringArgs = null, params object[] paramArgs)
Parameters
IDictionary<string, string> | stringArgs | Optional string named arguments for the constructor (can be null). |
object[] | paramArgs | Parameter arguments for the constructor. |
Returns
TService | A new instance of type |
Type Parameters
TService | The type of the instance. |
Remarks
This method relies on the Activator.CreateInstance or constructor invocation to create the new instance and is not optimized for performance. It is fine to use it for e.g. creating singletons when the application starts, but it should not be used for intensive creation of objects.
CreateInstance<TService, TActual>(IDictionary<string, string>, params object[])
Creates a new instance of type TActual
as TService
.
Declaration
public static TService CreateInstance<TService, TActual>(IDictionary<string, string> stringArgs = null, params object[] paramArgs) where TActual : TService
Parameters
IDictionary<string, string> | stringArgs | Optional string named arguments for the constructor (can be null). |
object[] | paramArgs | Parameter arguments for the constructor. |
Returns
TService | A new instance of type |
Type Parameters
TService | The type of the returned instance. |
TActual | The type of the created instance. |
Remarks
This method relies on the Activator.CreateInstance or constructor invocation to create the new instance and is not optimized for performance. It is fine to use it for e.g. creating singletons when the application starts, but it should not be used for intensive creation of objects.
CreateInstance<TService>(Type, IDictionary<string, string>, params object[])
Creates a new instance of type type
as TService
.
Declaration
public static TService CreateInstance<TService>(Type type, IDictionary<string, string> stringArgs = null, params object[] paramArgs)
Parameters
Type | type | The type of the created instance. |
IDictionary<string, string> | stringArgs | Optional string named arguments for the constructor (can be null). |
object[] | paramArgs | Parameter arguments for the constructor. |
Returns
TService | A new instance of type |
Type Parameters
TService | The type of the returned instance. |
Remarks
This method relies on the Activator.CreateInstance or constructor invocation to create the new instance and is not optimized for performance. It is fine to use it for e.g. creating singletons when the application starts, but it should not be used for intensive creation of objects.
CreateInstance<TService>(string, IDictionary<string, string>, params object[])
Creates a new instance of type typeName
as TService
.
Declaration
public static TService CreateInstance<TService>(string typeName, IDictionary<string, string> stringArgs = null, params object[] paramArgs)
Parameters
string | typeName | The name of the type of the created instance. |
IDictionary<string, string> | stringArgs | Optional string named arguments for the constructor (can be null). |
object[] | paramArgs | Parameter arguments for the constructor. |
Returns
TService | A new instance of type |
Type Parameters
TService | The type of the returned instance. |
Remarks
This method relies on the Activator.CreateInstance or constructor invocation to create the new instance and is not optimized for performance. It is fine to use it for e.g. creating singletons when the application starts, but it should not be used for intensive creation of objects.
CreateInstance(Type, IDictionary<string, string>, params object[])
Creates a new instance of type type
.
Declaration
public static object CreateInstance(Type type, IDictionary<string, string> stringArgs = null, params object[] paramArgs)
Parameters
Type | type | The type of the instance. |
IDictionary<string, string> | stringArgs | Optional string named arguments for the constructor (can be null). |
object[] | paramArgs | Parameter arguments for the constructor. |
Returns
object | A new instance of type |
Remarks
This method relies on the Activator.CreateInstance or constructor invocation to create the new instance and is not optimized for performance. It is fine to use it for e.g. creating singletons when the application starts, but it should not be used for intensive creation of objects.
CreateInstance(string, IDictionary<string, string>, params object[])
Creates a new instance of type typeName
.
Declaration
public static object CreateInstance(string typeName, IDictionary<string, string> stringArgs = null, params object[] paramArgs)
Parameters
string | typeName | The name of the type of the instance. |
IDictionary<string, string> | stringArgs | Optional string named arguments for the constructor (can be null). |
object[] | paramArgs | Parameter arguments for the constructor. |
Returns
object | A new instance of type |
Remarks
This method relies on the Activator.CreateInstance or constructor invocation to create the new instance and is not optimized for performance. It is fine to use it for e.g. creating singletons when the application starts, but it should not be used for intensive creation of objects.