Remove database properties from IScope
This commit is contained in:
18
src/Umbraco.Infrastructure/Scoping/IDatabaseScope.cs
Normal file
18
src/Umbraco.Infrastructure/Scoping/IDatabaseScope.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Umbraco.Cms.Core.Scoping;
|
||||
using Umbraco.Cms.Infrastructure.Persistence;
|
||||
|
||||
namespace Umbraco.Cms.Infrastructure.Scoping
|
||||
{
|
||||
public interface IDatabaseScope : IScope
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the scope database.
|
||||
/// </summary>
|
||||
IUmbracoDatabase Database { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Sql context.
|
||||
/// </summary>
|
||||
ISqlContext SqlContext { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
using System;
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Infrastructure.Persistence;
|
||||
|
||||
namespace Umbraco.Cms.Core.Scoping
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a scope.
|
||||
/// </summary>
|
||||
public interface IScope : IDisposable, IInstanceIdentifiable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the scope database.
|
||||
/// </summary>
|
||||
IUmbracoDatabase Database { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Sql context.
|
||||
/// </summary>
|
||||
ISqlContext SqlContext { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scope notification publisher
|
||||
/// </summary>
|
||||
IScopedNotificationPublisher Notifications { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the repositories cache mode.
|
||||
/// </summary>
|
||||
RepositoryCacheMode RepositoryCacheMode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scope isolated cache.
|
||||
/// </summary>
|
||||
IsolatedCaches IsolatedCaches { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Completes the scope.
|
||||
/// </summary>
|
||||
/// <returns>A value indicating whether the scope has been successfully completed.</returns>
|
||||
/// <remarks>Can return false if any child scope has not completed.</remarks>
|
||||
bool Complete();
|
||||
|
||||
/// <summary>
|
||||
/// Read-locks some lock objects.
|
||||
/// </summary>
|
||||
/// <param name="lockIds">Array of lock object identifiers.</param>
|
||||
void ReadLock(params int[] lockIds);
|
||||
|
||||
/// <summary>
|
||||
/// Write-locks some lock objects.
|
||||
/// </summary>
|
||||
/// <param name="lockIds">Array of object identifiers.</param>
|
||||
void WriteLock(params int[] lockIds);
|
||||
|
||||
/// <summary>
|
||||
/// Write-locks some lock objects.
|
||||
/// </summary>
|
||||
/// <param name="timeout">The database timeout in milliseconds</param>
|
||||
/// <param name="lockId">The lock object identifier.</param>
|
||||
void WriteLock(TimeSpan timeout, int lockId);
|
||||
|
||||
/// <summary>
|
||||
/// Read-locks some lock objects.
|
||||
/// </summary>
|
||||
/// <param name="timeout">The database timeout in milliseconds</param>
|
||||
/// <param name="lockId">The lock object identifier.</param>
|
||||
void ReadLock(TimeSpan timeout, int lockId);
|
||||
|
||||
void EagerWriteLock(params int[] lockIds);
|
||||
|
||||
void EagerWriteLock(TimeSpan timeout, int lockId);
|
||||
|
||||
void EagerReadLock(TimeSpan timeout, int lockId);
|
||||
|
||||
void EagerReadLock(params int[] lockIds);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,11 @@
|
||||
// Copyright (c) Umbraco.
|
||||
// See LICENSE for more details.
|
||||
|
||||
namespace Umbraco.Cms.Core.Scoping
|
||||
namespace Umbraco.Cms.Infrastructure.Scoping
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides access to the ambient scope.
|
||||
/// </summary>
|
||||
public interface IScopeAccessor
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the ambient scope.
|
||||
/// </summary>
|
||||
/// <remarks>Returns <c>null</c> if there is no ambient scope.</remarks>
|
||||
IScope AmbientScope { get; }
|
||||
IDatabaseScope AmbientScope { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
using System.Data;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Persistence.Querying;
|
||||
using Umbraco.Cms.Infrastructure.Persistence;
|
||||
|
||||
#if DEBUG_SCOPES
|
||||
using System.Collections.Generic;
|
||||
#endif
|
||||
|
||||
namespace Umbraco.Cms.Core.Scoping
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides scopes.
|
||||
/// </summary>
|
||||
public interface IScopeProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates an ambient scope.
|
||||
/// </summary>
|
||||
/// <param name="isolationLevel">The transaction isolation level.</param>
|
||||
/// <param name="repositoryCacheMode">The repositories cache mode.</param>
|
||||
/// <param name="scopedNotificationPublisher">An optional notification publisher.</param>
|
||||
/// <param name="scopeFileSystems">A value indicating whether to scope the filesystems.</param>
|
||||
/// <param name="callContext">A value indicating whether this scope should always be registered in the call context.</param>
|
||||
/// <param name="autoComplete">A value indicating whether this scope is auto-completed.</param>
|
||||
/// <returns>The created ambient scope.</returns>
|
||||
/// <remarks>
|
||||
/// <para>The created scope becomes the ambient scope.</para>
|
||||
/// <para>If an ambient scope already exists, it becomes the parent of the created scope.</para>
|
||||
/// <para>When the created scope is disposed, the parent scope becomes the ambient scope again.</para>
|
||||
/// <para>Parameters must be specified on the outermost scope, or must be compatible with the parents.</para>
|
||||
/// <para>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.</para>
|
||||
/// </remarks>
|
||||
IScope CreateScope(
|
||||
IsolationLevel isolationLevel = IsolationLevel.Unspecified,
|
||||
RepositoryCacheMode repositoryCacheMode = RepositoryCacheMode.Unspecified,
|
||||
IScopedNotificationPublisher scopedNotificationPublisher = null,
|
||||
bool? scopeFileSystems = null,
|
||||
bool callContext = false,
|
||||
bool autoComplete = false);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a detached scope.
|
||||
/// </summary>
|
||||
/// <returns>A detached scope.</returns>
|
||||
/// <param name="isolationLevel">The transaction isolation level.</param>
|
||||
/// <param name="repositoryCacheMode">The repositories cache mode.</param>
|
||||
/// <param name="scopedNotificationPublisher">An option notification publisher.</param>
|
||||
/// <param name="scopeFileSystems">A value indicating whether to scope the filesystems.</param>
|
||||
/// <remarks>
|
||||
/// <para>A detached scope is not ambient and has no parent.</para>
|
||||
/// <para>It is meant to be attached by <see cref="AttachScope"/>.</para>
|
||||
/// </remarks>
|
||||
// TODO: This is not actually used apart from unit tests - I'm assuming it's maybe used by Deploy?
|
||||
IScope CreateDetachedScope(
|
||||
IsolationLevel isolationLevel = IsolationLevel.Unspecified,
|
||||
RepositoryCacheMode repositoryCacheMode = RepositoryCacheMode.Unspecified,
|
||||
IScopedNotificationPublisher scopedNotificationPublisher = null,
|
||||
bool? scopeFileSystems = null);
|
||||
|
||||
/// <summary>
|
||||
/// Attaches a scope.
|
||||
/// </summary>
|
||||
/// <param name="scope">The scope to attach.</param>
|
||||
/// <param name="callContext">A value indicating whether to force usage of call context.</param>
|
||||
/// <remarks>
|
||||
/// <para>Only a scope created by <see cref="CreateDetachedScope"/> can be attached.</para>
|
||||
/// </remarks>
|
||||
void AttachScope(IScope scope, bool callContext = false);
|
||||
|
||||
/// <summary>
|
||||
/// Detaches a scope.
|
||||
/// </summary>
|
||||
/// <returns>The detached scope.</returns>
|
||||
/// <remarks>
|
||||
/// <para>Only a scope previously attached by <see cref="AttachScope"/> can be detached.</para>
|
||||
/// </remarks>
|
||||
IScope DetachScope();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scope context.
|
||||
/// </summary>
|
||||
IScopeContext Context { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sql context.
|
||||
/// </summary>
|
||||
ISqlContext SqlContext { get; }
|
||||
|
||||
IQuery<T> CreateQuery<T>();
|
||||
|
||||
#if DEBUG_SCOPES
|
||||
|
||||
IEnumerable<ScopeInfo> ScopeInfos { get; }
|
||||
ScopeInfo GetScopeInfo(IScope scope);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ using Umbraco.Cms.Core.Configuration.Models;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.IO;
|
||||
using Umbraco.Cms.Infrastructure.Persistence;
|
||||
using Umbraco.Cms.Infrastructure.Scoping;
|
||||
using Umbraco.Core.Collections;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
@@ -19,7 +20,7 @@ namespace Umbraco.Cms.Core.Scoping
|
||||
/// Implements <see cref="IScope" />.
|
||||
/// </summary>
|
||||
/// <remarks>Not thread-safe obviously.</remarks>
|
||||
internal class Scope : IScope
|
||||
internal class Scope : IDatabaseScope
|
||||
{
|
||||
private readonly bool _autoComplete;
|
||||
private readonly CoreDebugSettings _coreDebugSettings;
|
||||
|
||||
@@ -12,6 +12,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading;
|
||||
using Umbraco.Cms.Core.Persistence.Querying;
|
||||
using Umbraco.Cms.Infrastructure.Scoping;
|
||||
|
||||
#if DEBUG_SCOPES
|
||||
using System.Linq;
|
||||
@@ -286,10 +287,10 @@ namespace Umbraco.Cms.Core.Scoping
|
||||
|
||||
#region Ambient Scope
|
||||
|
||||
IScope IScopeAccessor.AmbientScope => AmbientScope;
|
||||
IDatabaseScope IScopeAccessor.AmbientScope => AmbientScope;
|
||||
|
||||
/// <summary>
|
||||
/// Get or set the Ambient (Current) <see cref="Scope"/> for the current execution context.
|
||||
/// Gets or set the Ambient (Current) <see cref="Scope"/> for the current execution context.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The current execution context may be request based (HttpContext) or on a background thread (AsyncLocal)
|
||||
|
||||
Reference in New Issue
Block a user