Scope Class

Simple Injector
Implements a cache for ScopedLifestyle implementations.
Inheritance Hierarchy

SystemObject
  SimpleInjectorScope

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

public class Scope : IDisposable

The Scope type exposes the following members.

Constructors

  NameDescription
Public methodScope
Initializes a new instance of the Scope class.
Public methodScope(Container)
Initializes a new instance of the Scope class.
Top
Properties

  NameDescription
Public propertyContainer
Gets the container instance that this scope belongs to.
Top
Methods

  NameDescription
Public methodDispose
Releases all instances that are cached by the Scope object.
Protected methodDispose(Boolean)
Releases all instances that are cached by the Scope object.
Public methodGetItem
Retrieves an item from the scope stored by the given key or null when no item is stored by that key.
Public methodRegisterForDisposal
Adds the disposable to the list of items that will get disposed when the scope ends.
Public methodSetItem
Stores an item by the given key in the scope.
Public methodWhenScopeEnds
Allows registering an action delegate that will be called when the scope ends, but before the scope disposes any instances.
Top
Remarks

Scope is thread-safe can be used over multiple threads concurrently, but note that the cached instances might not be thread-safe.
See Also

Reference