Scope Class

Simple Injector
Implements a cache for ScopedLifestyle implementations.
Inheritance Hierarchy

SystemObject
  SimpleInjector.AdvancedApiObject
    SimpleInjectorScope

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

public class Scope : ApiObject, IDisposable, 
	IServiceProvider

The Scope type exposes the following members.

Constructors

  NameDescription
Public methodScope Obsolete.
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 methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from ApiObject.)
Public methodGetDisposables
Returns the list of IDisposable instances that will be disposed of when this Scope instance is being disposed. The list contains scoped instances that are cached in this Scope instance, and instances explicitly registered for disposal using RegisterForDisposal(IDisposable). The instances are returned in order of creation/registration. When Scope.Dispose is called, the scope will ensure Dispose is called on each instance in this list. The instance will be disposed in opposite order as they appear in the list.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from ApiObject.)
Public methodGetInstance(Type)
Gets an instance of the given serviceType for the current scope.
Public methodGetInstanceTService
Gets an instance of the given TService for the current scope.
Public methodGetItem
Retrieves an item from the scope stored by the given key or null when no item is stored by that key.
Public methodGetType
Gets the Type of the current instance.
(Inherited from ApiObject.)
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 methodToString
Returns a string that represents the current object.
(Inherited from ApiObject.)
Public methodWhenScopeEnds
Allows registering an action delegate that will be called when the scope ends, but before the scope disposes any instances.
Top
Extension Methods

  NameDescription
Public Extension MethodUseSimpleInjector(Container)Overloaded.
Finalizes the configuration of Simple Injector on top of IServiceCollection. Will ensure framework components can be injected into Simple Injector-resolved components, unless AutoCrossWireFrameworkComponents is set to false.
(Defined by SimpleInjectorServiceCollectionExtensions.)
Public Extension MethodUseSimpleInjector(Container, ActionSimpleInjectorUseOptions)Overloaded.
Finalizes the configuration of Simple Injector on top of IServiceCollection. Will ensure framework components can be injected into Simple Injector-resolved components, unless AutoCrossWireFrameworkComponents is set to false using the setupAction.
(Defined by SimpleInjectorServiceCollectionExtensions.)
Top
Explicit Interface Implementations

  NameDescription
Explicit interface implementationPrivate methodIServiceProviderGetService
Gets the service object of the specified type.
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