From ff4bdb25091ee4907d766aecd1a3c6d70b06ed29 Mon Sep 17 00:00:00 2001 From: yv01p Date: Mon, 22 Dec 2025 23:20:35 +0000 Subject: [PATCH] refactor(core): add QueryOperationService to ContentService facade MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injects IContentQueryOperationService for future delegation. Includes lazy resolution support for obsolete constructors. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/Umbraco.Core/Services/ContentService.cs | 30 ++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index e91a26542d..f69ab4867a 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -51,6 +51,18 @@ public class ContentService : RepositoryService, IContentService // Property for convenient access (deferred resolution for both paths) private IContentCrudService CrudService => _crudServiceLazy.Value; + // Query operation service fields (for Phase 2 extracted query operations) + private readonly IContentQueryOperationService? _queryOperationService; + private readonly Lazy? _queryOperationServiceLazy; + + /// + /// Gets the query operation service. + /// + /// Thrown if the service was not properly initialized. + private IContentQueryOperationService QueryOperationService => + _queryOperationService ?? _queryOperationServiceLazy?.Value + ?? throw new InvalidOperationException("QueryOperationService not initialized. Ensure the service is properly injected via constructor."); + #region Constructors [Microsoft.Extensions.DependencyInjection.ActivatorUtilitiesConstructor] @@ -72,7 +84,8 @@ public class ContentService : RepositoryService, IContentService IIdKeyMap idKeyMap, IOptionsMonitor optionsMonitor, IRelationService relationService, - IContentCrudService crudService) // NEW PARAMETER - direct injection + IContentCrudService crudService, + IContentQueryOperationService queryOperationService) // NEW PARAMETER - Phase 2 query operations : base(provider, loggerFactory, eventMessagesFactory) { _documentRepository = documentRepository; @@ -97,6 +110,11 @@ public class ContentService : RepositoryService, IContentService ArgumentNullException.ThrowIfNull(crudService); // Wrap in Lazy for consistent access pattern (already resolved, so returns immediately) _crudServiceLazy = new Lazy(() => crudService); + + // Phase 2: Query operation service (direct injection) + ArgumentNullException.ThrowIfNull(queryOperationService); + _queryOperationService = queryOperationService; + _queryOperationServiceLazy = null; // Not needed when directly injected } [Obsolete("Use the non-obsolete constructor instead. Scheduled removal in v19.")] @@ -148,6 +166,11 @@ public class ContentService : RepositoryService, IContentService _crudServiceLazy = new Lazy(() => StaticServiceProvider.Instance.GetRequiredService(), LazyThreadSafetyMode.ExecutionAndPublication); + + // Phase 2: Lazy resolution of IContentQueryOperationService + _queryOperationServiceLazy = new Lazy(() => + StaticServiceProvider.Instance.GetRequiredService(), + LazyThreadSafetyMode.ExecutionAndPublication); } [Obsolete("Use the non-obsolete constructor instead. Scheduled removal in v19.")] @@ -198,6 +221,11 @@ public class ContentService : RepositoryService, IContentService _crudServiceLazy = new Lazy(() => StaticServiceProvider.Instance.GetRequiredService(), LazyThreadSafetyMode.ExecutionAndPublication); + + // Phase 2: Lazy resolution of IContentQueryOperationService + _queryOperationServiceLazy = new Lazy(() => + StaticServiceProvider.Instance.GetRequiredService(), + LazyThreadSafetyMode.ExecutionAndPublication); } #endregion