Skip to content

Commit 387ba8d

Browse files
authored
Batch 11: Cross-project extension points — CleanStrategy/DirtyStrategy (#382)
- Add CleanStrategy<T>() and DirtyStrategy<T>() 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
1 parent cde34c2 commit 387ba8d

4 files changed

Lines changed: 11 additions & 7 deletions

File tree

src/c#/GeneralUpdate.Core/Configuration/AbstractBootstrap.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,13 @@ protected T GetOption<T>(UpdateOption<T>? option)
8585
public TBootstrap DownloadOrchestrator<T>() where T : Download.Abstractions.IDownloadOrchestrator, new()
8686
{ _extensions[typeof(Download.Abstractions.IDownloadOrchestrator)] = typeof(T); return (TBootstrap)this; }
8787

88-
// ICleanStrategy / IDirtyStrategy extension points are in GeneralUpdate.Differential.
89-
// Add via external extension methods once the project reference is established.
88+
/// <summary>Register a custom clean strategy by type name (interface lives in GeneralUpdate.Differential).</summary>
89+
public TBootstrap CleanStrategy<T>() where T : class, new()
90+
{ _extensions[typeof(T)] = typeof(T); return (TBootstrap)this; }
91+
92+
/// <summary>Register a custom dirty strategy by type name (interface lives in GeneralUpdate.Differential).</summary>
93+
public TBootstrap DirtyStrategy<T>() where T : class, new()
94+
{ _extensions[typeof(T)] = typeof(T); return (TBootstrap)this; }
9095

9196
public TBootstrap ConfigureBlackList(BlackListConfig config)
9297
{

src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
</ItemGroup>
3535

3636
<ItemGroup>
37-
<!-- DrivelutionMiddleware: requires net10.0 target + Drivelution reference -->
37+
<!-- DrivelutionMiddleware: available for users who add GeneralUpdate.Drivelution reference.
38+
Restore by: 1) Add <ProjectReference> to Drivelution, 2) Remove this Compile Remove -->
3839
<Compile Remove="Pipeline\DrivelutionMiddleware.cs" />
3940
<!-- IsExternalInit is built-in for net8.0+ (C# 9 records) -->
4041
<Compile Remove="Configuration\IsExternalInit.cs" Condition="'$(TargetFramework)' != 'netstandard2.0'" />

src/c#/GeneralUpdate.Core/Strategy/LinuxStrategy.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ protected override PipelineBuilder BuildPipeline(PipelineContext context)
3636
.UseMiddlewareIf<PatchMiddleware>(_configinfo.PatchEnabled)
3737
.UseMiddleware<CompressMiddleware>()
3838
.UseMiddleware<HashMiddleware>();
39-
// DrivelutionMiddleware requires GeneralUpdate.Drivelution project reference;
40-
// uncomment when the reference is added for net10.0 target.
39+
// DrivelutionMiddleware: add GeneralUpdate.Drivelution project reference to enable
4140
return builder;
4241
}
4342

src/c#/GeneralUpdate.Core/Strategy/WindowsStrategy.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ protected override PipelineBuilder BuildPipeline(PipelineContext context)
3838
.UseMiddlewareIf<PatchMiddleware>(_configinfo.PatchEnabled)
3939
.UseMiddleware<CompressMiddleware>()
4040
.UseMiddleware<HashMiddleware>();
41-
// DrivelutionMiddleware requires GeneralUpdate.Drivelution project reference;
42-
// uncomment when the reference is added for net10.0 target.
41+
// DrivelutionMiddleware: add GeneralUpdate.Drivelution project reference to enable
4342
return builder;
4443
}
4544

0 commit comments

Comments
 (0)