diff --git a/src/Umbraco.Core/Scoping/IScopeContext.cs b/src/Umbraco.Core/Scoping/IScopeContext.cs
new file mode 100644
index 0000000000..73a04751b9
--- /dev/null
+++ b/src/Umbraco.Core/Scoping/IScopeContext.cs
@@ -0,0 +1,42 @@
+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 commited.
+ public interface IScopeContext
+ {
+ ///
+ /// 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);
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Scoping/IScopeInternal.cs b/src/Umbraco.Core/Scoping/IScopeInternal.cs
deleted file mode 100644
index 220b6456a7..0000000000
--- a/src/Umbraco.Core/Scoping/IScopeInternal.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-using System.Data;
-using Umbraco.Core.Events;
-using Umbraco.Core.Persistence;
-
-namespace Umbraco.Core.Scoping
-{
- ///
- /// Provides additional, internal scope functionnalities.
- ///
- internal interface IScopeInternal : IScope // fixme - define what's internal and why
- {
- ///
- /// Gets the parent scope, if any, or null.
- ///
- IScopeInternal ParentScope { get; }
-
- ///
- /// Gets a value indicating whether this scope should be registered in
- /// call context even when an http context is available.
- ///
- bool CallContext { get; }
-
- ///
- /// Gets the scope transaction isolation level.
- ///
- IsolationLevel IsolationLevel { get; }
-
- ///
- /// Gets the scope database, if any, else null.
- ///
- IUmbracoDatabase DatabaseOrNull { get; }
-
- ///
- /// Get the scope event messages, if any, else null.
- ///
- EventMessages MessagesOrNull { get; }
-
- ///
- /// Gets a value indicating whether filesystems are scoped.
- ///
- bool ScopedFileSystems { get; }
-
- ///
- /// Registers that a child has completed.
- ///
- /// The child's completion status.
- /// Completion status can be true (completed), false (could not complete), or null (not properly exited).
- void ChildCompleted(bool? completed);
-
- ///
- /// Resets the scope.
- ///
- /// Reset completion to "unspecified".
- void Reset();
- }
-}
diff --git a/src/Umbraco.Core/Scoping/IScopeProvider.cs b/src/Umbraco.Core/Scoping/IScopeProvider.cs
index 3be0f73a98..fa8cbf72e5 100644
--- a/src/Umbraco.Core/Scoping/IScopeProvider.cs
+++ b/src/Umbraco.Core/Scoping/IScopeProvider.cs
@@ -74,7 +74,7 @@ namespace Umbraco.Core.Scoping
///
/// Gets the scope context.
///
- ScopeContext Context { get; }
+ IScopeContext Context { get; }
#if DEBUG_SCOPES
Dictionary CallContextObjects { get; }
diff --git a/src/Umbraco.Core/Scoping/Scope.cs b/src/Umbraco.Core/Scoping/Scope.cs
index 51084f026a..dbeb5f1d0d 100644
--- a/src/Umbraco.Core/Scoping/Scope.cs
+++ b/src/Umbraco.Core/Scoping/Scope.cs
@@ -14,7 +14,7 @@ namespace Umbraco.Core.Scoping
/// Implements .
///
/// Not thread-safe obviously.
- internal class Scope : IScopeInternal
+ internal class Scope : IScope
{
// fixme
// considering that a great amount of things here are only useful for the top-level
@@ -182,12 +182,12 @@ namespace Umbraco.Core.Scoping
public bool Detachable { get; }
// the parent scope (in a nested scopes chain)
- public IScopeInternal ParentScope { get; set; }
+ public Scope ParentScope { get; set; }
public bool Attached { get; set; }
// the original scope (when attaching a detachable scope)
- public IScopeInternal OrigScope { get; set; }
+ public Scope OrigScope { get; set; }
// the original context (when attaching a detachable scope)
public ScopeContext OrigContext { get; set; }
diff --git a/src/Umbraco.Core/Scoping/ScopeContext.cs b/src/Umbraco.Core/Scoping/ScopeContext.cs
index 6172fb51a3..97b655ed63 100644
--- a/src/Umbraco.Core/Scoping/ScopeContext.cs
+++ b/src/Umbraco.Core/Scoping/ScopeContext.cs
@@ -4,10 +4,7 @@ using System.Linq;
namespace Umbraco.Core.Scoping
{
- // fixme should we have an IScopeContext?
- // fixme document all this properly!
-
- public class ScopeContext : IInstanceIdentifiable
+ internal class ScopeContext : IScopeContext, IInstanceIdentifiable
{
private Dictionary _enlisted;
private bool _exiting;
@@ -62,7 +59,7 @@ namespace Umbraco.Core.Scoping
public T Item { get; }
- public int Priority { get; private set; }
+ public int Priority { get; }
public void Execute(bool completed)
{
@@ -70,38 +67,19 @@ namespace Umbraco.Core.Scoping
}
}
- // todo: replace with optional parameters when we can break things
- public T Enlist(string key, Func creator)
- {
- return Enlist(key, creator, null, 100);
- }
-
- // todo: replace with optional parameters when we can break things
- public T Enlist(string key, Func creator, Action action)
- {
- return Enlist(key, creator, action, 100);
- }
-
- // todo: replace with optional parameters when we can break things
- public void Enlist(string key, Action action)
- {
- Enlist