Show / Hide Table of Contents

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
System.Object
ObjectFactory
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Juhta.Net.Common
Assembly: Juhta.Net.dll
Syntax
public static class ObjectFactory

Methods

| Improve this Doc View Source

CreateInstance<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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 libraryFile.

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.

| Improve this Doc View Source

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 libraryFile.

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.

  • Improve this Doc
  • View Source
Back to top Copyright © 2017-2019 Juha Lähteenmäki
Generated by DocFX