Spring.NET 1.3.0 RC1 for .NET 2.0 API Reference

ObjectFactoryUtils.ObjectOfType(IListableObjectFactory, Type, Boolean, Boolean) 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, _
   ByVal includePrototypes As Boolean, _
   ByVal includeFactoryObjects As Boolean _
)
[C#]
public static object ObjectOfType(
   IListableObjectFactory factory,
   Type type,
   bool includePrototypes,
   bool includeFactoryObjects
);

Parameters

factory
The object factory.
type
The Type of object to match.
includePrototypes
Whether to include prototype objects too or just singletons (also applies to IFactoryObject instances).
includeFactoryObjects
Whether to include IFactoryObject instances too or just normal objects.

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.

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