Class ContainerControlledLifetimeManager
Unity returns the same instance each time the Resolve(...) method is called or when the dependency mechanism injects the instance into other classes.
public class ContainerControlledLifetimeManager : SynchronizedLifetimeManager, IDisposable, IInstanceLifetimeManager, IFactoryLifetimeManager, ITypeLifetimeManager
  - Inheritance
 - 
      
      
      
      ContainerControlledLifetimeManager
 
- Implements
 
- Derived
 
- Inherited Members
 
- Extension Methods
 
Remarks
Per Container lifetime allows a registration of an existing or resolved object as a scoped singleton in the container it was created or registered. In other words this instance is unique within the container it war registered with. Child or parent containers could have their own instances registered for the same contract.
When the ContainerControlledLifetimeManager is disposed, the instance is disposed with it.
Constructors
ContainerControlledLifetimeManager()
public ContainerControlledLifetimeManager()
  Fields
Value
An instance of the object this manager is associated with.
protected object Value
  Field Value
- object
 This field holds a strong reference to the associated object.
Properties
Scope
public object Scope { get; set; }
  Property Value
Methods
Dispose(bool)
Standard Dispose pattern implementation.
protected override void Dispose(bool disposing)
  Parameters
disposingboolAlways true, since we don't have a finalizer.
GetValue(ILifetimeContainer)
Retrieves a value from the backing store associated with this Lifetime policy.
public override object GetValue(ILifetimeContainer container = null)
  Parameters
containerILifetimeContainerThe container this lifetime is associated with
Returns
- object
 the object desired, or null if no such object is currently stored.
OnCreateLifetimeManager()
Implementation of CreateLifetimePolicy() policy.
protected override LifetimeManager OnCreateLifetimeManager()
  Returns
- LifetimeManager
 A new instance of the same lifetime manager of appropriate type
RemoveValue(ILifetimeContainer)
Remove the given object from backing store.
public override void RemoveValue(ILifetimeContainer container = null)
  Parameters
containerILifetimeContainerThe container this lifetime belongs to
SetValue(object, ILifetimeContainer)
Stores the given value into backing store for retrieval later.
public override void SetValue(object newValue, ILifetimeContainer container = null)
  Parameters
newValueobjectThe object being stored.
containerILifetimeContainerThe container this lifetime is associated with
SynchronizedGetValue(ILifetimeContainer)
Performs the actual retrieval of a value from the backing store associated with this Lifetime policy.
protected override object SynchronizedGetValue(ILifetimeContainer container = null)
  Parameters
containerILifetimeContainerInstance of the lifetime's container
Returns
- object
 the object desired, or null if no such object is currently stored.
Remarks
This method is invoked by GetValue(ILifetimeContainer) after it has acquired its lock.
SynchronizedSetValue(object, ILifetimeContainer)
Performs the actual storage of the given value into backing store for retrieval later.
protected override void SynchronizedSetValue(object newValue, ILifetimeContainer container = null)
  Parameters
newValueobjectThe object being stored.
containerILifetimeContainerInstance of the lifetime's container
Remarks
This method is invoked by SetValue(object, ILifetimeContainer) before releasing its lock.
ToString()
This method provides human readable representation of the lifetime
public override string ToString()
  Returns
- string
 Name of the lifetime