Show / Hide Table of Contents

Class SingletonLifetimeManager

Singleton lifetime creates globally unique singleton. Any Unity container tree (parent and all the children) is guaranteed to have only one global singleton for the registered type.

Inheritance
Object
LifetimeManager
SynchronizedLifetimeManager
ContainerControlledLifetimeManager
SingletonLifetimeManager
Implements
IDisposable
IInstanceLifetimeManager
IFactoryLifetimeManager
ITypeLifetimeManager
Inherited Members
ContainerControlledLifetimeManager.Value
ContainerControlledLifetimeManager.Scope
ContainerControlledLifetimeManager.GetValue(ILifetimeContainer)
ContainerControlledLifetimeManager.SetValue(Object, ILifetimeContainer)
ContainerControlledLifetimeManager.SynchronizedGetValue(ILifetimeContainer)
ContainerControlledLifetimeManager.SynchronizedSetValue(Object, ILifetimeContainer)
ContainerControlledLifetimeManager.RemoveValue(ILifetimeContainer)
ContainerControlledLifetimeManager.OnCreateLifetimeManager()
ContainerControlledLifetimeManager.Dispose(Boolean)
SynchronizedLifetimeManager.ResolveTimeout
SynchronizedLifetimeManager.TryGetValue(ILifetimeContainer)
SynchronizedLifetimeManager.Recover()
SynchronizedLifetimeManager.TryExit()
SynchronizedLifetimeManager.Dispose()
LifetimeManager.NoValue
LifetimeManager.InUse
LifetimeManager.TryGet
LifetimeManager.Get
LifetimeManager.Set
LifetimeManager.CreateLifetimePolicy()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Namespace: Unity.Lifetime
Assembly: Unity.Abstractions.dll
Syntax
public class SingletonLifetimeManager : ContainerControlledLifetimeManager, IDisposable, IInstanceLifetimeManager, IFactoryLifetimeManager, ITypeLifetimeManager
Remarks

Registering a type with singleton lifetime always places the registration at the root of the container tree and makes it globally available for all the children of that container. It does not matter if registration takes places at the root of child container the destination is always the root node.

Repeating the registration on any of the child nodes with singleton lifetime will always override the root registration.

When the SingletonLifetimeManager is disposed, the instance it holds is disposed with it.

Methods

| Improve this Doc View Source

ToString()

This method provides human readable representation of the lifetime

Declaration
public override string ToString()
Returns
Type Description
String

Name of the lifetime

Overrides
ContainerControlledLifetimeManager.ToString()

Implements

System.IDisposable
IInstanceLifetimeManager
IFactoryLifetimeManager
ITypeLifetimeManager

Extension Methods

InjectionMatching.Matches(Object, Type)
InjectionMatching.MatchesObject(Object, Type)
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2020 .NET Foundation and Contributors. All Rights Reserved