Begins a new scope for the given container.
Services, registered using the ThreadScopedLifestyle are cached during the
lifetime of that scope. The scope should be disposed explicitly.
Namespace: SimpleInjector.Lifestyles
Assembly: SimpleInjector (in SimpleInjector.dll) Version: 5.3.0
Syntax
Parameters
- container
- Type: SimpleInjectorContainer
The container.
Return Value
Type: ScopeA new Scope instance.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | Thrown when the container is a null reference. |
Examples
C#
using (ThreadScopedLifestyle.BeginScope()) { var handler = (IRequestHandler)container.GetInstance(handlerType); handler.Handle(request); }
See Also