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.
Inheritance
Inherited Members
Namespace: Unity.Lifetime
Assembly: Unity.Abstractions.dll
Syntax
public class ContainerControlledLifetimeManager : SynchronizedLifetimeManager, IDisposable, IInstanceLifetimeManager, IFactoryLifetimeManager, ITypeLifetimeManager
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
| Improve this Doc View SourceContainerControlledLifetimeManager()
Declaration
public ContainerControlledLifetimeManager()
Fields
| Improve this Doc View SourceValue
An instance of the object this manager is associated with.
Declaration
protected object Value
Field Value
Type | Description |
---|---|
Object | This field holds a strong reference to the associated object. |
Properties
| Improve this Doc View SourceScope
Declaration
public object Scope { get; set; }
Property Value
Type | Description |
---|---|
Object |
Methods
| Improve this Doc View SourceDispose(Boolean)
Standard Dispose pattern implementation.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing | Always true, since we don't have a finalizer. |
Overrides
| Improve this Doc View SourceGetValue(ILifetimeContainer)
Retrieves a value from the backing store associated with this Lifetime policy.
Declaration
public override object GetValue(ILifetimeContainer container = null)
Parameters
Type | Name | Description |
---|---|---|
ILifetimeContainer | container | The container this lifetime is associated with |
Returns
Type | Description |
---|---|
Object | the object desired, or null if no such object is currently stored. |
Overrides
| Improve this Doc View SourceOnCreateLifetimeManager()
Implementation of CreateLifetimePolicy() policy.
Declaration
protected override LifetimeManager OnCreateLifetimeManager()
Returns
Type | Description |
---|---|
LifetimeManager | A new instance of the same lifetime manager of appropriate type |
Overrides
| Improve this Doc View SourceRemoveValue(ILifetimeContainer)
Remove the given object from backing store.
Declaration
public override void RemoveValue(ILifetimeContainer container = null)
Parameters
Type | Name | Description |
---|---|---|
ILifetimeContainer | container | The container this lifetime belongs to |
Overrides
| Improve this Doc View SourceSetValue(Object, ILifetimeContainer)
Stores the given value into backing store for retrieval later.
Declaration
public override void SetValue(object newValue, ILifetimeContainer container = null)
Parameters
Type | Name | Description |
---|---|---|
Object | newValue | The object being stored. |
ILifetimeContainer | container | The container this lifetime is associated with |
Overrides
| Improve this Doc View SourceSynchronizedGetValue(ILifetimeContainer)
Performs the actual retrieval of a value from the backing store associated with this Lifetime policy.
Declaration
protected override object SynchronizedGetValue(ILifetimeContainer container = null)
Parameters
Type | Name | Description |
---|---|---|
ILifetimeContainer | container | Instance of the lifetime's container |
Returns
Type | Description |
---|---|
Object | the object desired, or null if no such object is currently stored. |
Overrides
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.
Declaration
protected override void SynchronizedSetValue(object newValue, ILifetimeContainer container = null)
Parameters
Type | Name | Description |
---|---|---|
Object | newValue | The object being stored. |
ILifetimeContainer | container | Instance of the lifetime's container |
Overrides
Remarks
This method is invoked by SetValue(Object, ILifetimeContainer) before releasing its lock.
ToString()
This method provides human readable representation of the lifetime
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | Name of the lifetime |