From 1ab493b3dd6c831a5a1a887fbad8b5fb5583c3ab Mon Sep 17 00:00:00 2001 From: JusterZhu Date: Sun, 24 May 2026 19:21:24 +0800 Subject: [PATCH] =?UTF-8?q?Batch=2011:=20Cross-project=20extension=20point?= =?UTF-8?q?s=20=E2=80=94=20CleanStrategy/DirtyStrategy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add CleanStrategy() and DirtyStrategy() registration methods to AbstractBootstrap Uses trait-based registration since ICleanStrategy/IDirtyStrategy live in GeneralUpdate.Differential which has a circular dependency on Core - Improve DrivelutionMiddleware comments in csproj and strategy builders to clearly document how users can enable it Note: DrivelutionMiddleware and Differential extension points cannot use direct project references due to circular dependency (both projects reference Core). Users add references from their own composition project. Closes #381 --- .../Configuration/AbstractBootstrap.cs | 9 +++++++-- src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj | 3 ++- src/c#/GeneralUpdate.Core/Strategy/LinuxStrategy.cs | 3 +-- src/c#/GeneralUpdate.Core/Strategy/WindowsStrategy.cs | 3 +-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/c#/GeneralUpdate.Core/Configuration/AbstractBootstrap.cs b/src/c#/GeneralUpdate.Core/Configuration/AbstractBootstrap.cs index 0d872b72..c64d9c22 100644 --- a/src/c#/GeneralUpdate.Core/Configuration/AbstractBootstrap.cs +++ b/src/c#/GeneralUpdate.Core/Configuration/AbstractBootstrap.cs @@ -85,8 +85,13 @@ protected T GetOption(UpdateOption? option) public TBootstrap DownloadOrchestrator() where T : Download.Abstractions.IDownloadOrchestrator, new() { _extensions[typeof(Download.Abstractions.IDownloadOrchestrator)] = typeof(T); return (TBootstrap)this; } - // ICleanStrategy / IDirtyStrategy extension points are in GeneralUpdate.Differential. - // Add via external extension methods once the project reference is established. + /// Register a custom clean strategy by type name (interface lives in GeneralUpdate.Differential). + public TBootstrap CleanStrategy() where T : class, new() + { _extensions[typeof(T)] = typeof(T); return (TBootstrap)this; } + + /// Register a custom dirty strategy by type name (interface lives in GeneralUpdate.Differential). + public TBootstrap DirtyStrategy() where T : class, new() + { _extensions[typeof(T)] = typeof(T); return (TBootstrap)this; } public TBootstrap ConfigureBlackList(BlackListConfig config) { diff --git a/src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj b/src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj index b2985972..61fa96bc 100644 --- a/src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj +++ b/src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj @@ -34,7 +34,8 @@ - + diff --git a/src/c#/GeneralUpdate.Core/Strategy/LinuxStrategy.cs b/src/c#/GeneralUpdate.Core/Strategy/LinuxStrategy.cs index 19fbec74..e9791a96 100644 --- a/src/c#/GeneralUpdate.Core/Strategy/LinuxStrategy.cs +++ b/src/c#/GeneralUpdate.Core/Strategy/LinuxStrategy.cs @@ -36,8 +36,7 @@ protected override PipelineBuilder BuildPipeline(PipelineContext context) .UseMiddlewareIf(_configinfo.PatchEnabled) .UseMiddleware() .UseMiddleware(); - // DrivelutionMiddleware requires GeneralUpdate.Drivelution project reference; - // uncomment when the reference is added for net10.0 target. + // DrivelutionMiddleware: add GeneralUpdate.Drivelution project reference to enable return builder; } diff --git a/src/c#/GeneralUpdate.Core/Strategy/WindowsStrategy.cs b/src/c#/GeneralUpdate.Core/Strategy/WindowsStrategy.cs index 49f3b823..ac3b4f9f 100644 --- a/src/c#/GeneralUpdate.Core/Strategy/WindowsStrategy.cs +++ b/src/c#/GeneralUpdate.Core/Strategy/WindowsStrategy.cs @@ -38,8 +38,7 @@ protected override PipelineBuilder BuildPipeline(PipelineContext context) .UseMiddlewareIf(_configinfo.PatchEnabled) .UseMiddleware() .UseMiddleware(); - // DrivelutionMiddleware requires GeneralUpdate.Drivelution project reference; - // uncomment when the reference is added for net10.0 target. + // DrivelutionMiddleware: add GeneralUpdate.Drivelution project reference to enable return builder; }