Search Results for

    Show / Hide Table of Contents
    View Source

    Interface IScopeContext

    Represents a scope context.

    Namespace: Umbraco.Cms.Core.Scoping
    Assembly: Umbraco.Core.dll
    Syntax
    public interface IScopeContext : IInstanceIdentifiable
    Remarks

    A scope context can enlist objects that will be attached to the scope, and available for the duration of the scope. In addition, it can enlist actions, that will run when the scope is exiting, and after the database transaction has been committed.

    Methods

    View Source

    Enlist(String, Action<Boolean>, Int32)

    Enlists an action.

    Declaration
    void Enlist(string key, Action<bool> action, int priority = 100)
    Parameters
    Type Name Description
    System.String key

    The action unique identifier.

    Action<System.Boolean> action

    The action.

    System.Int32 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.

    View Source

    Enlist<T>(String, Func<T>, Nullable<Action<Boolean, T>>, Int32)

    Enlists an object and action.

    Declaration
    T Enlist<T>(string key, Func<T> creator, Action<bool, T>? action = null, int priority = 100)
    Parameters
    Type Name Description
    System.String key

    The object unique identifier.

    Func<T> creator

    A function providing the object.

    System.Nullable<Action<System.Boolean, T>> action

    The optional action.

    System.Int32 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.

    View Source

    GetEnlisted<T>(String)

    Gets an enlisted object.

    Declaration
    T GetEnlisted<T>(string key)
    Parameters
    Type Name Description
    System.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.

    View Source

    ScopeExit(Boolean)

    Declaration
    void ScopeExit(bool completed)
    Parameters
    Type Name Description
    System.Boolean completed
    • Improve this Doc
    • View Source
    In This Article
    • Methods
      • Enlist(String, Action<Boolean>, Int32)
      • Enlist<T>(String, Func<T>, Nullable<Action<Boolean, T>>, Int32)
      • GetEnlisted<T>(String)
      • ScopeExit(Boolean)
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX