Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/c#/GeneralUpdate.Core/Configuration/AbstractBootstrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ protected internal AbstractBootstrap()
PopulateDefaults();
}

/// <summary>
/// Populate all UpdateOptions with their best-practice defaults.
/// Subclasses can override to customize.
/// </summary>
protected virtual void PopulateDefaults()
{
Option(UpdateOptions.MaxConcurrency, 3);
Expand All @@ -45,9 +41,6 @@ protected virtual void PopulateDefaults()
protected abstract Task ExecuteStrategyAsync();
protected abstract TBootstrap StrategyFactory();

/// <summary>
/// Setting update configuration.
/// </summary>
public TBootstrap Option<T>(UpdateOption<T> option, T value)
{
if (value == null)
Expand Down Expand Up @@ -86,6 +79,9 @@ public TBootstrap Option<T>(UpdateOption<T> option, T value)
public TBootstrap BinaryDiffer<T>() where T : Differential.IBinaryDiffer, new()
{ _extensions[typeof(Differential.IBinaryDiffer)] = typeof(T); return (TBootstrap)this; }

public TBootstrap PipelineFactory<T>() where T : Pipeline.IUpdatePipelineFactory, new()
{ _extensions[typeof(Pipeline.IUpdatePipelineFactory)] = typeof(T); return (TBootstrap)this; }

public TBootstrap DownloadPolicy<T>() where T : Download.Abstractions.IDownloadPolicy, new()
{ _extensions[typeof(Download.Abstractions.IDownloadPolicy)] = typeof(T); return (TBootstrap)this; }

Expand All @@ -95,6 +91,9 @@ public TBootstrap Option<T>(UpdateOption<T> option, T value)
public TBootstrap DownloadSource<T>() where T : Download.Abstractions.IDownloadSource, new()
{ _extensions[typeof(Download.Abstractions.IDownloadSource)] = typeof(T); return (TBootstrap)this; }

public TBootstrap DownloadPipeline<T>() where T : Download.Abstractions.IDownloadPipeline, new()
{ _extensions[typeof(Download.Abstractions.IDownloadPipeline)] = typeof(T); return (TBootstrap)this; }
Comment on lines +94 to +95

public TBootstrap UpdateReporter<T>() where T : Download.Reporting.IUpdateReporter, new()
{ _extensions[typeof(Download.Reporting.IUpdateReporter)] = typeof(T); return (TBootstrap)this; }

Expand Down
39 changes: 39 additions & 0 deletions src/c#/GeneralUpdate.Core/FileSystem/BlackListConfigBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System.Collections.Generic;
using GeneralUpdate.Core.Configuration;

namespace GeneralUpdate.Core.FileSystem;

/// <summary>
/// Fluent builder for <see cref="BlackListConfig"/>.
/// Used via <c>Bootstrap.ConfigureBlackList(cfg => cfg.AddBlackFiles(...))</c>.
/// </summary>
public class BlackListConfigBuilder
{
private readonly List<string> _blackFiles = new();
private readonly List<string> _blackFormats = new();
private readonly List<string> _skipDirectories = new();

public BlackListConfigBuilder AddBlackFiles(params string[] files)
{
_blackFiles.AddRange(files);
return this;
}

public BlackListConfigBuilder AddBlackFormats(params string[] formats)
{
_blackFormats.AddRange(formats);
return this;
}

public BlackListConfigBuilder AddSkipDirectories(params string[] directories)
{
_skipDirectories.AddRange(directories);
return this;
}
Comment on lines +16 to +32

public BlackListConfig Build() => new(
BlackFiles: _blackFiles.Count > 0 ? _blackFiles.AsReadOnly() : null,
BlackFormats: _blackFormats.Count > 0 ? _blackFormats.AsReadOnly() : null,
SkipDirectorys: _skipDirectories.Count > 0 ? _skipDirectories.AsReadOnly() : null
);
Comment on lines +34 to +38
}
14 changes: 14 additions & 0 deletions src/c#/GeneralUpdate.Core/Pipeline/IUpdatePipelineFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Threading;
using System.Threading.Tasks;

namespace GeneralUpdate.Core.Pipeline;

/// <summary>
/// Factory for creating update pipelines.
/// Injected via <c>Bootstrap.PipelineFactory&lt;T&gt;()</c>.
/// </summary>
public interface IUpdatePipelineFactory
{
/// <summary>Create a pipeline for the given context.</summary>
Task ExecutePipelineAsync(PipelineContext context, CancellationToken token = default);
Comment on lines +6 to +13
}