Class FactoryUtils
Provides helper methods for dynamic object creation and configuration
Inheritance
System.Object
FactoryUtils
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()
Assembly: Azos.dll
Syntax
public static class FactoryUtils
Fields
CONFIG_TYPE_ATTR
Declaration
public const string CONFIG_TYPE_ATTR = "type"
Field Value
Type |
Description |
System.String |
|
Methods
Make<T>(IConfigSectionNode, Type, Object[])
Creates an instance of appropriate configurable object as specified by the supplied config node.
This function does not configure the instance
Declaration
public static T Make<T>(IConfigSectionNode node, Type defaultType = null, object[] args = null)
Parameters
Type |
Name |
Description |
IConfigSectionNode |
node |
|
System.Type |
defaultType |
|
System.Object[] |
args |
|
Returns
Type Parameters
Creates and configures an instance of appropriate configurable object as specified by the supplied config node.
Applies configured behaviors
Declaration
public static IConfigurable MakeAndConfigure(IConfigSectionNode node, Type defaultType = null, object[] args = null)
Parameters
Type |
Name |
Description |
IConfigSectionNode |
node |
|
System.Type |
defaultType |
|
System.Object[] |
args |
|
Returns
Creates and configures an instance of appropriate configurable object as specified by the supplied config node.
Applies configured behaviors
Declaration
public static T MakeAndConfigure<T>(IConfigSectionNode node, Type defaultType = null, object[] args = null)
where T : IConfigurable
Parameters
Type |
Name |
Description |
IConfigSectionNode |
node |
|
System.Type |
defaultType |
|
System.Object[] |
args |
|
Returns
Type Parameters
Creates and configures an instance of appropriate configurable component object as specified by the supplied config node.
Applies configured behaviors. By convention passes application as the first constructor argument.
Extra arguments shall not contain application
Declaration
public static T MakeAndConfigureComponent<T>(IApplication app, IConfigSectionNode node, Type defaultType = null, object[] extraArgs = null)
where T : IApplicationComponent, IConfigurable
Parameters
Returns
Type Parameters
Creates and configures an instance of appropriate configurable component object as specified by the supplied config node.
Applies configured behaviors. By convention passes director as the first constructor argument.
Extra arguments shall not contain director
Declaration
public static T MakeAndConfigureDirectedComponent<T>(IApplicationComponent director, IConfigSectionNode node, Type defaultType = null, object[] extraArgs = null)
where T : IApplicationComponent, IConfigurable
Parameters
Returns
Type Parameters
MakeComponent<T>(IApplication, IConfigSectionNode, Type, Object[])
Creates an instance of appropriate component object as specified by the supplied config node.
By convention passes application as the first constructor argument.
Extra arguments shall not contain application
Declaration
public static T MakeComponent<T>(IApplication app, IConfigSectionNode node, Type defaultType = null, object[] extraArgs = null)
where T : IApplicationComponent
Parameters
Returns
Type Parameters
MakeDirectedComponent<T>(IApplicationComponent, IConfigSectionNode, Type, Object[])
Creates an instance of appropriate component object as specified by the supplied config node.
By convention passes director as the first constructor argument.
Extra arguments shall not contain director
Declaration
public static T MakeDirectedComponent<T>(IApplicationComponent director, IConfigSectionNode node, Type defaultType = null, object[] extraArgs = null)
where T : IApplicationComponent
Parameters
Returns
Type Parameters
MakeUsingCtor<T>(IConfigSectionNode, String)
Invokes a constructor for type feeding it the specified args:
node{type="NS.Type, Assembly" arg0=1 arg1=true....}
If the typePattern is passed, then the '*' in pattern is replaced with 'type' attr content.
This is needed for security, as this method allows to inject any type with any ctor params when typePattern is null
Declaration
public static T MakeUsingCtor<T>(IConfigSectionNode node, string typePattern = null)
Parameters
Returns
Type Parameters