Class ObjectFactory
A static class that provides services for creating instances of such classes whose type is not directly referencable in the current programming context. A typical scenario for using this class is to create instances of classes that are not available at the build time but are known to implement a specific interface.
Inheritance
Inherited Members
Namespace: Juhta.Net.Common
Assembly: Juhta.Net.dll
Syntax
public static class ObjectFactory
Methods
| Improve this Doc View SourceCreateInstance<T>(ClassId)
Creates an instance of a specified class by using the default constructor.
Declaration
public static T CreateInstance<T>(ClassId classId)
Parameters
Type | Name | Description |
---|---|---|
ClassId | classId | Specifies a ClassId object. |
Returns
Type | Description |
---|---|
T | Returns the created instance casted to the specified type. |
Type Parameters
Name | Description |
---|---|
T | Specifies a type for the return value. An instance to create must be castable to this type. |
CreateInstance<T>(ClassId, Object[])
Creates an instance of a specified class.
Declaration
public static T CreateInstance<T>(ClassId classId, params object[] parameters)
Parameters
Type | Name | Description |
---|---|---|
ClassId | classId | Specifies a ClassId object. |
System.Object[] | parameters | Specifies an array of parameters that will be passed to the appropriate constructor. Can be null causing the default constructor to be called. |
Returns
Type | Description |
---|---|
T | Returns the created instance casted to the specified type. |
Type Parameters
Name | Description |
---|---|
T | Specifies a type for the return value. An instance to create must be castable to this type. |
CreateInstance<T>(Assembly, String)
Creates an instance of a specified class by using the default constructor.
Declaration
public static T CreateInstance<T>(Assembly assembly, string className)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Assembly | assembly | Specifies an System.Reflection.Assembly object. |
System.String | className | Specifies a class name. The value can begin with a '~.' prefix in which case the root namespace for the class will be taken from the file name part of the System.Reflection.Assembly.Location property. |
Returns
Type | Description |
---|---|
T | Returns the created instance casted to the specified type. |
Type Parameters
Name | Description |
---|---|
T | Specifies a type for the return value. An instance to create must be castable to this type. |
CreateInstance<T>(Assembly, String, Object[])
Creates an instance of a specified class.
Declaration
public static T CreateInstance<T>(Assembly assembly, string className, params object[] parameters)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Assembly | assembly | Specifies an System.Reflection.Assembly object. |
System.String | className | Specifies a class name. The value can begin with a '~.' prefix in which case the root namespace for the class will be taken from the file name part of the System.Reflection.Assembly.Location property. |
System.Object[] | parameters | Specifies an array of parameters that will be passed to the appropriate constructor. Can be null causing the default constructor to be called. |
Returns
Type | Description |
---|---|
T | Returns the created instance casted to the specified type. |
Type Parameters
Name | Description |
---|---|
T | Specifies a type for the return value. An instance to create must be castable to this type. |
CreateInstance<T>(String, String)
Creates an instance of a specified class by using the default constructor.
Declaration
public static T CreateInstance<T>(string libraryFile, string className)
Parameters
Type | Name | Description |
---|---|---|
System.String | libraryFile | Specifies a library file. The value can have a directory part, either relative or absolute. |
System.String | className | Specifies a class name. The value can begin with a '~.' prefix in which case the
root namespace for the class will be taken from the file name part of |
Returns
Type | Description |
---|---|
T | Returns the created instance casted to the requested type. |
Type Parameters
Name | Description |
---|---|
T | Specifies a type for the return value. An instance to create must be castable to this type. |
CreateInstance<T>(String, String, Object[])
Creates an instance of a specified class.
Declaration
public static T CreateInstance<T>(string libraryFile, string className, params object[] parameters)
Parameters
Type | Name | Description |
---|---|---|
System.String | libraryFile | Specifies a library file. The value can have a directory part, either relative or absolute. |
System.String | className | Specifies a class name. The value can begin with a '~.' prefix in which case the
root namespace for the class will be taken from the file name part of |
System.Object[] | parameters | Specifies an array of parameters that will be passed to the appropriate constructor. Can be null causing the default constructor to be called. |
Returns
Type | Description |
---|---|
T | Returns the created instance casted to the requested type. |
Type Parameters
Name | Description |
---|---|
T | Specifies a type for the return value. An instance to create must be castable to this type. |