using System;
using System.Data;
using Umbraco.Core.Events;
using Umbraco.Core.Persistence;
#if DEBUG_SCOPES
using System.Collections.Generic;
#endif
namespace Umbraco.Core.Scoping
{
///
/// Provides scopes.
///
public interface IScopeProvider
{
///
/// Creates an ambient scope.
///
/// The transaction isolation level.
/// The repositories cache mode.
/// An optional events dispatcher.
/// A value indicating whether to scope the filesystems.
/// A value indicating whether this scope should always be registered in the call context.
/// A value indicating whether this scope is auto-completed.
/// The created ambient scope.
///
/// The created scope becomes the ambient scope.
/// If an ambient scope already exists, it becomes the parent of the created scope.
/// When the created scope is disposed, the parent scope becomes the ambient scope again.
/// Parameters must be specified on the outermost scope, or must be compatible with the parents.
/// Auto-completed scopes should be used for read-only operations ONLY. Do not use them if you do not
/// understand the associated issues, such as the scope being completed even though an exception is thrown.
///
IScope CreateScope(
IsolationLevel isolationLevel = IsolationLevel.Unspecified,
RepositoryCacheMode repositoryCacheMode = RepositoryCacheMode.Unspecified,
IEventDispatcher eventDispatcher = null,
bool? scopeFileSystems = null,
bool callContext = false,
bool autoComplete = false);
///
/// Creates a detached scope.
///
/// A detached scope.
/// The transaction isolation level.
/// The repositories cache mode.
/// An optional events dispatcher.
/// A value indicating whether to scope the filesystems.
///
/// A detached scope is not ambient and has no parent.
/// It is meant to be attached by .
///
IScope CreateDetachedScope(
IsolationLevel isolationLevel = IsolationLevel.Unspecified,
RepositoryCacheMode repositoryCacheMode = RepositoryCacheMode.Unspecified,
IEventDispatcher eventDispatcher = null,
bool? scopeFileSystems = null);
///
/// Attaches a scope.
///
/// The scope to attach.
/// A value indicating whether to force usage of call context.
///
/// Only a scope created by can be attached.
///
void AttachScope(IScope scope, bool callContext = false);
///
/// Detaches a scope.
///
/// The detached scope.
///
/// Only a scope previously attached by can be detached.
///
IScope DetachScope();
///
/// Gets the scope context.
///
IScopeContext Context { get; }
///
/// Gets the sql context.
///
ISqlContext SqlContext { get; }
#if DEBUG_SCOPES
Dictionary CallContextObjects { get; }
IEnumerable ScopeInfos { get; }
ScopeInfo GetScopeInfo(IScope scope);
#endif
}
}