Class ScopeContext
Inheritance
Namespace: Umbraco.Cms.Core.Scoping
Assembly: Umbraco.Infrastructure.dll
Syntax
public class ScopeContext : IScopeContext, IInstanceIdentifiable
Properties
View SourceCreatedThreadId
Declaration
public int CreatedThreadId { get; }
Property Value
| Type | Description |
|---|---|
| int |
InstanceId
Gets the instance unique identifier.
Declaration
public Guid InstanceId { get; }
Property Value
| Type | Description |
|---|---|
| Guid |
Methods
View SourceEnlist(string, Action<bool>, int)
Enlists an action.
Declaration
public void Enlist(string key, Action<bool> action, int priority = 100)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The action unique identifier. |
| Action<bool> | action | The action. |
| int | priority | The optional action priority (default is 100, lower runs first). |
Remarks
It is ok to enlist multiple action with the same key but only the first one will run.
The action boolean parameter indicates whether the scope completed or not.
Enlist<T>(string, Func<T>?, Action<bool, T?>?, int)
Enlists an object and action.
Declaration
public T? Enlist<T>(string key, Func<T>? creator, Action<bool, T?>? action = null, int priority = 100)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The object unique identifier. |
| Func<T> | creator | A function providing the object. |
| Action<bool, T> | action | The optional action. |
| int | priority | The optional action priority (default is 100, lower runs first). |
Returns
| Type | Description |
|---|---|
| T | The object. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the object. |
Remarks
On the first time an object is enlisted with a given key, the object is actually created. Next calls just return the existing object. It is ok to enlist multiple objects and action with the same key but only the first one is used, the others are ignored.
The action boolean parameter indicates whether the scope completed or not.
GetEnlisted<T>(string)
Gets an enlisted object.
Declaration
public T? GetEnlisted<T>(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The object unique identifier. |
Returns
| Type | Description |
|---|---|
| T | The enlisted object, if any, else the default value. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the object. |
ScopeExit(bool)
Declaration
public void ScopeExit(bool completed)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | completed |