Spring.NET 1.3.0 RC1 for .NET 2.0 API Reference

ObjectFactoryUtils.ObjectOfType(IListableObjectFactory, Type) Method

Return a single object of the given type or subtypes, not looking in ancestor factories.

[Visual Basic]
Public Overloads Shared Sub ObjectOfType( _
   ByVal factory As IListableObjectFactory, _
   ByVal type As Type _
)
[C#]
public static object ObjectOfType(
   IListableObjectFactory factory,
   Type type
);

Parameters

factory
The object factory.
type
The Type of object to match.

Return Value

A single object of the given type or subtypes.

Remarks

Useful convenience method when we expect a single object and don't care about the object name. This version of ObjectOfType automatically includes prototypes and IFactoryObject instances.

Exceptions

Exception Type Condition
ObjectsException If the object could not be created.
NoSuchObjectDefinitionException If not exactly one instance of an object was found.

See Also

ObjectFactoryUtils Class | Spring.Objects.Factory Namespace | ObjectFactoryUtils.ObjectOfType Overload List