Spring.NET 1.3.0 RC1 for .NET 2.0 API Reference

AbstractAutowireCapableObjectFactory.InstantiateUsingFactoryMethod Method

Instantiate an object instance using a named factory method.

[Visual Basic]
Protected Overridable Sub InstantiateUsingFactoryMethod( _
   ByVal name As String, _
   ByVal definition As RootObjectDefinition, _
   ByVal arguments As Object _
)
[C#]
protected virtual IObjectWrapper InstantiateUsingFactoryMethod(
   string name,
   RootObjectDefinition definition,
   object[] arguments
);

Parameters

name
The name associated with the supplied definition.
definition
The definition describing the instance that is to be instantiated.
arguments
Any arguments to the factory method that is to be invoked.

Return Value

The result of the factory method invocation (the instance).

Remarks

The method may be static, if the definition parameter specifies a class, rather than a IFactoryObject instance, or an instance variable on a factory object itself configured using Dependency Injection.

Implementation requires iterating over the static or instance methods with the name specified in the supplied definition (the method may be overloaded) and trying to match with the parameters. We don't have the types attached to constructor args, so trial and error is the only way to go here.

See Also

AbstractAutowireCapableObjectFactory Class | Spring.Objects.Factory.Support Namespace