Badge | |
---|---|
Target Frameworks |
Pipes.Net aims to bundle reoccuring simple workflows in an interactive object structure.
It can be easily extended with new nodes and features, as well as modifying the existing features to match any challenges.
The library is published to NuGet and can be installed through the .NET CLI
> dotnet add package Pipes.Net
or the Visual Studio Package Manager
PM> Install-Package Pipes.Net
Every Piece of Code utilizing Pipes.Net needs to include the following using clauses:
using Pipes.Net;
using Pipes.Net.Extensions;
Pipelines can be created using an Factory Pattern:
var factory = new PipelineFactory();
var pipeline = factory.Build();
You can add content to the pipeline using the specified Factory functions:
var pipeline = new PipelineFactory()
.AddAction(() => Console.WriteLine("Hello World"))
.Build();
From default there are additional Items enabling a more complex possibility of building Pipelines:
var pipeline = new PipelineFactory()
.AddDecision<int>(x => x >= 30, success =>
success.AddAction<int>((score) => Console.WriteLine($"Passed Test with a score of {score}"))
.AddAction<int>((score) => 6-5 * score / 100)
.AddSplit(MergeConditions.AllFinished,
x => x.AddAction<int>((grade) => Console.WriteLine($"Grade: {grade}")),
x => x.AddAction(() => Console.WriteLine("Storing Grade on Server"))
.AddAction(() => Thread.Sleep(3000))// Simulate some sort of Time consuming Action
)
.AddAction(() => Console.WriteLine($"Grading and uploading has finished"))
,failure => failure.AddAction((score) => Console.WriteLine($"Score of {score} does not qualify as a passing score"))
).Build();
The Pipeline can then be run like this:
await pipeline.Run(56);
and the Output will look like this:
Passed Test with a score of 56
Grade: 4
Storing Grade on Server
Grading and uploading has finished
You can also run the same Pipeline multiple times using different Inputs:
await pipeline.Run(98);
that will result in different Outputs
Passed Test with a score of 98
Grade: 2
Storing Grade on Server
Grading and uploading has finished
Head to the wiki for more examples, or check out the code of the example project.
You are welcome to share any improvement Ideas or Bugs you encoutered in the issues page.
It is greatly appreciated if you take the time to fork and contribute to this project.