UnityContainerBase.RegisterInstance<TInterface> Method (TInterface)

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Unity Application Block information can be found at the Unity Application Block site.

RegisterType an instance with the container.

Namespace:  Microsoft.Practices.Unity
Assembly:  Microsoft.Practices.Unity (in Microsoft.Practices.Unity.dll)

Syntax

'Declaration
Public Function RegisterInstance(Of TInterface) ( _
    instance As TInterface _
) As IUnityContainer
public IUnityContainer RegisterInstance<TInterface>(
    TInterface instance
)
public:
generic<typename TInterface>
virtual IUnityContainer^ RegisterInstance(
    TInterface instance
) sealed
JScript does not support generic types or methods.

Parameters

  • instance
    Type: TInterface
    Object to returned.

Type Parameters

  • TInterface
    Type of instance to register (may be an implemented interface instead of the full type).

Return Value

The UnityContainer object that this method was called on (this in C#, Me in Visual Basic).

Implements

IUnityContainer.RegisterInstance<TInterface>(TInterface)

Remarks

Instance registration is much like setting a type as a singleton, except that instead of the container creating the instance the first time it is requested, the user creates the instance ahead of type and adds that instance to the container.

This overload does a default registration and has the container take over the lifetime of the instance.

See Also

UnityContainerBase Class

RegisterInstance Overload

Microsoft.Practices.Unity Namespace