LifestyleScoped Field

Simple Injector

The lifestyle that caches components according to the lifetime of the container's configured scoped lifestyle.

In case the type of a cached instance implements IDisposable, the container will ensure its disposal when the active scope gets disposed.

Namespace:  SimpleInjector
Assembly:  SimpleInjector (in SimpleInjector.dll) Version: 5.3.0
Syntax

public static readonly ScopedLifestyle Scoped

Field Value

Type: ScopedLifestyle
Examples

The following example registers the RealTimeProvider implementation for the ITimeProvider service type using the Scoped lifestyle:
C#
// Create a Container instance, configured with a scoped lifestyle.
var container = new Container(new WebRequestLifestyle());

container.Register<ITimeProvider, RealTimeProvider>(Lifestyle.Scoped);
See Also

Reference