using System; namespace Umbraco.Core.Scoping { /// /// Represents a scope context. /// /// 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. public interface IScopeContext : IInstanceIdentifiable { /// /// Enlists an action. /// /// The action unique identifier. /// The action. /// The optional action priority (default is 100, lower runs first). /// /// 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. /// void Enlist(string key, Action action, int priority = 100); /// /// Enlists an object and action. /// /// The type of the object. /// The object unique identifier. /// A function providing the object. /// The optional action. /// The optional action priority (default is 100, lower runs first). /// The object. /// /// 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. /// T Enlist(string key, Func creator, Action action = null, int priority = 100); /// /// Gets an enlisted object. /// /// The type of the object. /// The object unique identifier. /// The enlisted object, if any, else the default value. T GetEnlisted(string key); void ScopeExit(bool completed); } }