Table of Contents

Class ExecutableExtensions

Namespace
Executables
Assembly
executables.dll

Extension methods for composing and adapting executables.

public static class ExecutableExtensions
Inheritance
ExecutableExtensions
Inherited Members

Methods

Accumulate<T1, T2, T3>(IExecutable<T1, T2>, Func<T2, T3>)

Appends a projection while preserving the previous result in the returned tuple.

[Pure]
public static IExecutable<T1, (T2, T3)> Accumulate<T1, T2, T3>(this IExecutable<T1, T2> first, Func<T2, T3> second)

Parameters

first IExecutable<T1, T2>

Executable that produces the value passed to second.

second Func<T2, T3>

Delegate that computes an additional value from the result of first.

Returns

IExecutable<T1, (T2, T3)>

Executable that returns both the original result and the appended value.

Type Parameters

T1
T2
T3

Exceptions

ArgumentNullException

second is null.

Accumulate<T1, T2, T3, T4>(IExecutable<T1, (T2, T3)>, Func<T2, T3, T4>)

Appends a projection while preserving the accumulated tuple produced by the previous stage.

[Pure]
public static IExecutable<T1, (T2, T3, T4)> Accumulate<T1, T2, T3, T4>(this IExecutable<T1, (T2, T3)> first, Func<T2, T3, T4> second)

Parameters

first IExecutable<T1, (T2, T3)>

Executable that produces the tuple passed to second.

second Func<T2, T3, T4>

Delegate that computes an additional value from the accumulated tuple items.

Returns

IExecutable<T1, (T2, T3, T4)>

Executable that returns the original tuple items plus the appended value.

Type Parameters

T1
T2
T3
T4

Exceptions

ArgumentNullException

second is null.

Accumulate<T1, T2, T3, T4, T5>(IExecutable<T1, (T2, T3, T4)>, Func<T2, T3, T4, T5>)

Appends a projection while preserving the accumulated tuple produced by the previous stage.

[Pure]
public static IExecutable<T1, (T2, T3, T4, T5)> Accumulate<T1, T2, T3, T4, T5>(this IExecutable<T1, (T2, T3, T4)> first, Func<T2, T3, T4, T5> second)

Parameters

first IExecutable<T1, (T2, T3, T4)>

Executable that produces the tuple passed to second.

second Func<T2, T3, T4, T5>

Delegate that computes an additional value from the accumulated tuple items.

Returns

IExecutable<T1, (T2, T3, T4, T5)>

Executable that returns the original tuple items plus the appended value.

Type Parameters

T1
T2
T3
T4
T5

Exceptions

ArgumentNullException

second is null.

AsCommand<T>(ICommand<T>)

Returns the same command instance.

[Pure]
public static ICommand<T> AsCommand<T>(this ICommand<T> command)

Parameters

command ICommand<T>

Returns

ICommand<T>

The original command.

Type Parameters

T

AsCommand<T>(IExecutable<T, bool>)

Converts an executable to a command.

[Pure]
public static ICommand<T> AsCommand<T>(this IExecutable<T, bool> executable)

Parameters

executable IExecutable<T, bool>

Returns

ICommand<T>

Command wrapping the executable.

Type Parameters

T

AsExecutable<T1, T2>(IExecutable<T1, T2>)

Returns the same executable instance.

[Pure]
public static IExecutable<T1, T2> AsExecutable<T1, T2>(this IExecutable<T1, T2> executable)

Parameters

executable IExecutable<T1, T2>

Returns

IExecutable<T1, T2>

Type Parameters

T1
T2

AsHandler<T1, T2>(Handler<T1, T2>)

Returns the same handler instance.

[Pure]
public static Handler<T1, T2> AsHandler<T1, T2>(this Handler<T1, T2> handler)

Parameters

handler Handler<T1, T2>

Returns

Handler<T1, T2>

The original handler.

Type Parameters

T1
T2

AsHandler<T1, T2>(IExecutable<T1, T2>)

Converts an executable to a handler.

[Pure]
public static Handler<T1, T2> AsHandler<T1, T2>(this IExecutable<T1, T2> executable)

Parameters

executable IExecutable<T1, T2>

Returns

Handler<T1, T2>

Handler wrapping the executable.

Type Parameters

T1
T2

AsQuery<T1, T2>(IExecutable<T1, T2>)

Converts an executable to a query.

[Pure]
public static IQuery<T1, T2> AsQuery<T1, T2>(this IExecutable<T1, T2> executable)

Parameters

executable IExecutable<T1, T2>

Returns

IQuery<T1, T2>

Query wrapping the executable.

Type Parameters

T1
T2

AsQuery<T1, T2>(IQuery<T1, T2>)

Returns the same query instance.

[Pure]
public static IQuery<T1, T2> AsQuery<T1, T2>(this IQuery<T1, T2> query)

Parameters

query IQuery<T1, T2>

Returns

IQuery<T1, T2>

The original query.

Type Parameters

T1
T2

AsSubscriber<T>(IExecutable<T, Unit>)

Converts an executable to a subscriber.

[Pure]
public static ISubscriber<T> AsSubscriber<T>(this IExecutable<T, Unit> executable)

Parameters

executable IExecutable<T, Unit>

Returns

ISubscriber<T>

Subscriber wrapping the executable.

Type Parameters

T

AsSubscriber<T>(ISubscriber<T>)

Returns the same subscriber instance.

[Pure]
public static ISubscriber<T> AsSubscriber<T>(this ISubscriber<T> subscriber)

Parameters

subscriber ISubscriber<T>

Returns

ISubscriber<T>

The original subscriber.

Type Parameters

T

First<T1, T2, T3, TNew>(IExecutable<T1, (T2, T3)>, IExecutable<T2, TNew>)

Maps the first item of a tuple result.

[Pure]
public static IExecutable<T1, (TNew, T3)> First<T1, T2, T3, TNew>(this IExecutable<T1, (T2, T3)> fork, IExecutable<T2, TNew> map)

Parameters

fork IExecutable<T1, (T2, T3)>

Executable that returns a tuple.

map IExecutable<T2, TNew>

Executable applied to the first tuple item.

Returns

IExecutable<T1, (TNew, T3)>

Executable with transformed first tuple item.

Type Parameters

T1
T2
T3
TNew

Exceptions

ArgumentNullException

map is null.

First<T1, T2, T3, TNew>(IExecutable<T1, (T2, T3)>, Func<T2, TNew>)

Maps the first item of a tuple result with a delegate.

[Pure]
public static IExecutable<T1, (TNew, T3)> First<T1, T2, T3, TNew>(this IExecutable<T1, (T2, T3)> fork, Func<T2, TNew> map)

Parameters

fork IExecutable<T1, (T2, T3)>

Executable that returns a tuple.

map Func<T2, TNew>

Delegate applied to the first tuple item.

Returns

IExecutable<T1, (TNew, T3)>

Executable with transformed first tuple item.

Type Parameters

T1
T2
T3
TNew

Exceptions

ArgumentNullException

map is null.

FlatMap<T1, T2, T3>(IExecutable<T1, T2>, IExecutable<T2, IExecutable<T2, T3>>)

Chains an executable with another executable-producing executable and flattens the nested result.

[Pure]
public static IExecutable<T1, T3> FlatMap<T1, T2, T3>(this IExecutable<T1, T2> first, IExecutable<T2, IExecutable<T2, T3>> second)

Parameters

first IExecutable<T1, T2>

Executable invoked first.

second IExecutable<T2, IExecutable<T2, T3>>

Executable that receives the result of first and returns the next executable to run.

Returns

IExecutable<T1, T3>

Executable that executes both stages as a single pipeline.

Type Parameters

T1
T2
T3

Exceptions

ArgumentNullException

second is null.

FlatMap<T1, T2, T3>(IExecutable<T1, T2>, Func<T2, IExecutable<T2, T3>>)

Chains an executable with a delegate that selects the next executable to run and flattens the nested result.

[Pure]
public static IExecutable<T1, T3> FlatMap<T1, T2, T3>(this IExecutable<T1, T2> first, Func<T2, IExecutable<T2, T3>> second)

Parameters

first IExecutable<T1, T2>

Executable invoked first.

second Func<T2, IExecutable<T2, T3>>

Delegate that receives the result of first and returns the next executable to run.

Returns

IExecutable<T1, T3>

Executable that executes both stages as a single pipeline.

Type Parameters

T1
T2
T3

Exceptions

ArgumentNullException

second is null.

Fork<T1, T2, T3, T4>(IExecutable<T1, T2>, IExecutable<T2, T3>, IExecutable<T2, T4>)

Branches execution into two executables and returns both results.

[Pure]
public static IExecutable<T1, (T3, T4)> Fork<T1, T2, T3, T4>(this IExecutable<T1, T2> executable, IExecutable<T2, T3> firstBranch, IExecutable<T2, T4> secondBranch)

Parameters

executable IExecutable<T1, T2>

Executable that produces the shared branch input.

firstBranch IExecutable<T2, T3>

First branch executable.

secondBranch IExecutable<T2, T4>

Second branch executable.

Returns

IExecutable<T1, (T3, T4)>

Executable that returns both branch results.

Type Parameters

T1
T2
T3
T4

Exceptions

ArgumentNullException

firstBranch or secondBranch is null.

Fork<T1, T2, T3, T4>(IExecutable<T1, T2>, Func<T2, T3>, Func<T2, T4>)

Branches execution into two delegates and returns both results.

[Pure]
public static IExecutable<T1, (T3, T4)> Fork<T1, T2, T3, T4>(this IExecutable<T1, T2> executable, Func<T2, T3> firstBranch, Func<T2, T4> secondBranch)

Parameters

executable IExecutable<T1, T2>

Executable that produces the shared branch input.

firstBranch Func<T2, T3>

First branch delegate.

secondBranch Func<T2, T4>

Second branch delegate.

Returns

IExecutable<T1, (T3, T4)>

Executable that returns both branch results.

Type Parameters

T1
T2
T3
T4

Exceptions

ArgumentNullException

firstBranch or secondBranch is null.

MapIso<T1, T2>(IExecutable<T2, T2>, IIso<T1, T2>)

Adapts an endomorphism through an isomorphism.

[Pure]
public static IExecutable<T1, T1> MapIso<T1, T2>(this IExecutable<T2, T2> executable, IIso<T1, T2> iso)

Parameters

executable IExecutable<T2, T2>

Executable that transforms values of type T2.

iso IIso<T1, T2>

Isomorphism used to convert values into and out of T2.

Returns

IExecutable<T1, T1>

Executable that transforms values of type T1 by mapping through iso.

Type Parameters

T1

External input and output type.

T2

Internal input and output type of the executable.

Map<T1, T2, T3, T4>(IExecutable<T2, T3>, Func<T1, T2>, Func<T3, T4>)

Adapts an executable to different external input and output types by applying delegate mappings around it.

[Pure]
public static IExecutable<T1, T4> Map<T1, T2, T3, T4>(this IExecutable<T2, T3> executable, Func<T1, T2> incoming, Func<T3, T4> outgoing)

Parameters

executable IExecutable<T2, T3>

Executable being adapted.

incoming Func<T1, T2>

Delegate that converts external input to the executable input type.

outgoing Func<T3, T4>

Delegate that converts executable output to the external output type.

Returns

IExecutable<T1, T4>

Executable with adapted input and output contracts.

Type Parameters

T1
T2
T3
T4

Exceptions

ArgumentNullException

incoming or outgoing is null.

Merge<T1, T2, T3, T4>(IExecutable<T1, (T2, T3)>, Func<T2, T3, T4>)

Merges a tuple result with a delegate.

[Pure]
public static IExecutable<T1, T4> Merge<T1, T2, T3, T4>(this IExecutable<T1, (T2, T3)> fork, Func<T2, T3, T4> merge)

Parameters

fork IExecutable<T1, (T2, T3)>

Executable that returns a tuple.

merge Func<T2, T3, T4>

Delegate that combines tuple items into a single result.

Returns

IExecutable<T1, T4>

Executable that returns the merged result.

Type Parameters

T1
T2
T3
T4

Exceptions

ArgumentNullException

merge is null.

Merge<T1, T2, T3, T4, T5>(IExecutable<T1, (T2, T3, T4)>, Func<T2, T3, T4, T5>)

Merges a three-item tuple result with a delegate.

[Pure]
public static IExecutable<T1, T5> Merge<T1, T2, T3, T4, T5>(this IExecutable<T1, (T2, T3, T4)> executable, Func<T2, T3, T4, T5> merge)

Parameters

executable IExecutable<T1, (T2, T3, T4)>

Executable that returns a three-item tuple.

merge Func<T2, T3, T4, T5>

Delegate that combines tuple items into a single result.

Returns

IExecutable<T1, T5>

Executable that returns the merged result.

Type Parameters

T1
T2
T3
T4
T5

Exceptions

ArgumentNullException

merge is null.

Merge<T1, T2, T3, T4, T5, T6>(IExecutable<T1, (T2, T3, T4, T5)>, Func<T2, T3, T4, T5, T6>)

Merges a four-item tuple result with a delegate.

[Pure]
public static IExecutable<T1, T6> Merge<T1, T2, T3, T4, T5, T6>(this IExecutable<T1, (T2, T3, T4, T5)> executable, Func<T2, T3, T4, T5, T6> merge)

Parameters

executable IExecutable<T1, (T2, T3, T4, T5)>

Executable that returns a four-item tuple.

merge Func<T2, T3, T4, T5, T6>

Delegate that combines tuple items into a single result.

Returns

IExecutable<T1, T6>

Executable that returns the merged result.

Type Parameters

T1
T2
T3
T4
T5
T6

Exceptions

ArgumentNullException

merge is null.

Second<T1, T2, T3, TNew>(IExecutable<T1, (T2, T3)>, IExecutable<T3, TNew>)

Maps the second item of a tuple result.

[Pure]
public static IExecutable<T1, (T2, TNew)> Second<T1, T2, T3, TNew>(this IExecutable<T1, (T2, T3)> fork, IExecutable<T3, TNew> map)

Parameters

fork IExecutable<T1, (T2, T3)>

Executable that returns a tuple.

map IExecutable<T3, TNew>

Executable applied to the second tuple item.

Returns

IExecutable<T1, (T2, TNew)>

Executable with transformed second tuple item.

Type Parameters

T1
T2
T3
TNew

Exceptions

ArgumentNullException

map is null.

Second<T1, T2, T3, TNew>(IExecutable<T1, (T2, T3)>, Func<T3, TNew>)

Maps the second item of a tuple result with a delegate.

[Pure]
public static IExecutable<T1, (T2, TNew)> Second<T1, T2, T3, TNew>(this IExecutable<T1, (T2, T3)> fork, Func<T3, TNew> map)

Parameters

fork IExecutable<T1, (T2, T3)>

Executable that returns a tuple.

map Func<T3, TNew>

Delegate applied to the second tuple item.

Returns

IExecutable<T1, (T2, TNew)>

Executable with transformed second tuple item.

Type Parameters

T1
T2
T3
TNew

Exceptions

ArgumentNullException

map is null.

Swap<T1, T2, T3>(IExecutable<T1, (T2, T3)>)

Swaps items in a tuple result.

[Pure]
public static IExecutable<T1, (T3, T2)> Swap<T1, T2, T3>(this IExecutable<T1, (T2, T3)> fork)

Parameters

fork IExecutable<T1, (T2, T3)>

Executable that returns a tuple.

Returns

IExecutable<T1, (T3, T2)>

Executable that returns the tuple with reversed item order.

Type Parameters

T1
T2
T3

ToAsyncExecutable<T1, T2>(IExecutable<T1, T2>)

Converts a synchronous executable to an asynchronous executable.

[Pure]
public static IAsyncExecutable<T1, T2> ToAsyncExecutable<T1, T2>(this IExecutable<T1, T2> executable)

Parameters

executable IExecutable<T1, T2>

Returns

IAsyncExecutable<T1, T2>

Asynchronous proxy executable.

Type Parameters

T1
T2