Scope Class
SystemObject
SimpleInjector.AdvancedApiObject
SimpleInjectorScope
Namespace:
SimpleInjector
Assembly:
SimpleInjector (in SimpleInjector.dll) Version: 5.3.0
public class Scope : ApiObject, IDisposable, IServiceProvider
The Scope type exposes the following members.
| Name | Description | |
|---|---|---|
| Scope | Obsolete. Initializes a new instance of the Scope class. | |
| Scope(Container) | Initializes a new instance of the Scope class. |
| Name | Description | |
|---|---|---|
| Container | Gets the container instance that this scope belongs to. |
| Name | Description | |
|---|---|---|
| Dispose | Releases all instances that are cached by the Scope object. | |
| Dispose(Boolean) | Releases all instances that are cached by the Scope object. | |
| DisposeScopeAsync | Releases all instances that are cached by the Scope object asynchronously. | |
| Equals | Determines whether the specified object is equal to the current object. (Inherited from ApiObject.) | |
| GetAllDisposables | Returns a copy of the list of IDisposable and IAsyncDisposable 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(Object). The instances are returned in order of creation. 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. | |
| GetDisposables | Returns a copy of 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. 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. | |
| GetHashCode | Serves as the default hash function. (Inherited from ApiObject.) | |
| GetInstance(Type) | Gets an instance of the given serviceType for the current scope. | |
| GetInstanceTService | Gets an instance of the given TService for the current scope. | |
| GetItem | Retrieves an item from the scope stored by the given key or null when no item is stored by that key. | |
| GetType | Gets the Type of the current instance. (Inherited from ApiObject.) | |
| RegisterForDisposal(IDisposable) | Adds the disposable to the list of items that will get disposed when the scope ends. | |
| RegisterForDisposal(Object) | Adds the disposable to the list of items that will get disposed when the scope ends. | |
| SetItem | Stores an item by the given key in the scope. | |
| ToString | Returns a string that represents the current object. (Inherited from ApiObject.) | |
| WhenScopeEnds | Allows registering an action delegate that will be called when the scope ends, but before the scope disposes any instances. |
Explicit Interface Implementations
| Name | Description | |
|---|---|---|
| IServiceProviderGetService | Gets the service object of the specified type. |
Scope is thread safe can be used over multiple threads concurrently, but methods that are related to the disposal of the Scope (e.g. GetDisposables, Dispose, and DisposeAsync() are not thread safe and can't be used in combination with the thread-safe methods. This means that once the Scope is ready for disposal, only a single thread should access it. Also note that although the scope is thread safe, cached instances might not be.