refactor: splitting out pipeline.AddDependency and AddDependencyList

This commit is contained in:
D. Moonfire 2024-03-07 21:33:24 -06:00
parent b131b84cd9
commit 76d52d9a54
4 changed files with 41 additions and 6 deletions

View file

@ -9,8 +9,13 @@ export DOTNET_CLI_TELEMETRY_OPTOUT := "1"
clean:
dotnet clean -v:m
# Formats everything in the package.
format:
treefmt
just --fmt --unstable
# Builds all of the components of this repository.
build:
build: format
dotnet build
# Runs all the known tests in the repository.

View file

@ -2,5 +2,4 @@
## Libraries
- [Gallium](./gallium/)
- [Nitride](./nitride/)
- [Gallium](./gallium/) - A simple Entity-Component-System (ECS) based on `System.Linq`

View file

@ -16,7 +16,7 @@ public class OutputPipeline1 : PipelineBase
public OutputPipeline1(ILogger logger, DelayPipeline1 delay1, InputPipeline2 input2)
{
this.logger = logger.ForContext<OutputPipeline1>();
this.AddDependency(delay1, input2);
this.AddDependencyList(delay1, input2);
}
/// <inheritdoc />

View file

@ -14,6 +14,20 @@ public abstract class PipelineBase : IPipeline
this.dependencies = new List<IPipeline>();
}
/// <summary>
/// Adds add a pipeline dependencies into the current one. All of
/// the dependencies are guaranteed to run before this pipeline's RunAsync
/// is called.
/// </summary>
/// <param name="pipelines">The pipelines to add as a dependency.</param>
/// <returns>The same object for chaining operations.</returns>
public PipelineBase AddDependency(IPipeline pipeline)
{
this.dependencies.Add(pipeline);
return this;
}
/// <summary>
/// Adds one or more pipeline dependencies into the current one. All of
/// the dependencies are guaranteed to run before this pipeline's RunAsync
@ -21,11 +35,28 @@ public abstract class PipelineBase : IPipeline
/// </summary>
/// <param name="pipelines">The pipelines to add as a dependency.</param>
/// <returns>The same object for chaining operations.</returns>
public PipelineBase AddDependency(params IPipeline[] pipelines)
public PipelineBase AddDependencyList(params IPipeline[] pipelines)
{
foreach (IPipeline pipeline in pipelines)
{
this.dependencies.Add(pipeline);
this.AddDependency(pipeline);
}
return this;
}
/// <summary>
/// Adds one or more pipeline dependencies into the current one. All of
/// the dependencies are guaranteed to run before this pipeline's RunAsync
/// is called.
/// </summary>
/// <param name="pipelines">The pipelines to add as a dependency.</param>
/// <returns>The same object for chaining operations.</returns>
public PipelineBase AddDependency(IEnumerable<IPipeline> pipelines)
{
foreach (IPipeline pipeline in pipelines)
{
this.AddDependency(pipeline);
}
return this;