CreateInstance Method
CreateInstance<T>(IDictionary<String, String>, Object[])
Creates a new instance of type T
.
Declaration
public static T CreateInstance<T>(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
T | A new instance of type |
Type Parameters
T | 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<T>(Type, IDictionary<String, String>, Object[])
Creates a new instance of type type
as T
.
Declaration
public static T CreateInstance<T>(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
T | A new instance of type |
Type Parameters
T | 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<T>(String, IDictionary<String, String>, Object[])
Creates a new instance of type typeName
as T
.
Declaration
public static T CreateInstance<T>(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
T | A new instance of type |
Type Parameters
T | 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>, 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>, 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.