The lifestyle that caches components during the lifetime of the Container instance and guarantees that only a single instance of that component is created for that instance. Since general use is to create a single Container instance for the lifetime of the application / AppDomain, this would mean that only a single instance of that component would exist during the lifetime of the application. In a multi-threaded applications, implementations registered using this lifestyle must be thread-safe.
In case the type of a cached instance implements IDisposable, the container will ensure its disposal when the container gets disposed.
Assembly: SimpleInjector (in SimpleInjector.dll) Version: 5.0.0
public static readonly SingletonLifestyle Singleton
Public Shared ReadOnly Singleton As SingletonLifestyle
Field ValueType: SingletonLifestyle
var container = new Container(); container.Register<ITimeProvider, RealTimeProvider>(Lifestyle.Singleton);