Skip to content

Latest commit

 

History

History
126 lines (92 loc) · 4.67 KB

PipelineActions.md

File metadata and controls

126 lines (92 loc) · 4.67 KB

Pipeline Actions

Contents

Joining pipes

When you have two inputs that are needed for the next piece of functionality, you need a JoinedPipe.

JoinedPipes produce a Tuple of two inputs.

Note: If you are using JoinedPipe you need to call Verify() with the join.

var input1 = new InputPipe<long>("value1");
var input2 = new InputPipe<long>("value2");
var join = input1.JoinTo(input2);

snippet source | anchor

will produce:

GraphViz of JoinedPipe

ApplyTo(list)

Sometimes you will want a special type of Join which takes one thing and applies it to each element of a separate list.

For example, if you had:

var apply = "#";
var to = new[] {1, 2};

snippet source | anchor

You can combine them to produce the following output:

var result = "[(#, 1), (#, 2)]";

snippet source | anchor

For reference you can do this manually (although it creates a bad visualization):

prefix.JoinTo(values).Process(t => t.Item2.Select(i => Tuple.Create(t.Item1, i)));

snippet source | anchor

However, if you use the ApplyTo() method, you will end up with a much better-rendered result.

GraphViz of AppliedPipe

ConcatWith(list)

Sometimes you will want a special type of Join which takes two enumerables of the same element type and concatenates them into a list.

For example, if you had:

var concat = new List<int> {1, 2};
var with = new[] {3, 4};

snippet source | anchor

You can combine them to produce the following output:

var result = "[1, 2, 3, 4]";

snippet source | anchor

For reference you can do this manually (although it creates a bad visualization):

part1.JoinTo(part2).Process(t => t.Item1.Concat(t.Item2).ToList());

snippet source | anchor

However, if you use the ConcatWith() method, you will end up with a much better-rendered result.

GraphViz of AppliedPipe

Processing a Lambda

the FunctionPipe uses the name of the function, but if you pass in a lambda it will format that nicely. For example:

var input = new InputPipe<int>("input");
input.Process(p => p.ToString());

snippet source | anchor

will look like:

GraphViz of Lambda