Spring.NET 1.3.0 RC1 for .NET 2.0 API Reference

ObjectFactoryUtils.ObjectOfTypeIncludingAncestors Method

Return a single object of the given type or subtypes, also picking up objects defined in ancestor object factories if the current object factory is an IHierarchicalObjectFactory.

[Visual Basic]
Public Shared Sub ObjectOfTypeIncludingAncestors( _
   ByVal factory As IListableObjectFactory, _
   ByVal type As Type, _
   ByVal includePrototypes As Boolean, _
   ByVal includeFactoryObjects As Boolean _
)
[C#]
public static object ObjectOfTypeIncludingAncestors(
   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 more than one instance of an object was found.

See Also

ObjectFactoryUtils Class | Spring.Objects.Factory Namespace