Table of Contents

Class CompositeExecutableExtensions

Namespace
Executables
Assembly
executables.dll

Extension methods for composing executables.

public static class CompositeExecutableExtensions
Inheritance
CompositeExecutableExtensions
Inherited Members

Methods

Compose<T>(IExecutable<Unit, T>, AsyncAction)

Prepends a parameterless asynchronous action to the current synchronous executable, creating a single asynchronous pipeline.

[Pure]
public static IAsyncExecutable<Unit, T> Compose<T>(this IExecutable<Unit, T> first, AsyncAction second)

Parameters

first IExecutable<Unit, T>

Synchronous executable invoked after second.

second AsyncAction

Parameterless asynchronous action invoked first.

Returns

IAsyncExecutable<Unit, T>

Asynchronous executable that runs second and then first.

Type Parameters

T

Exceptions

ArgumentNullException

second is null.

Compose<T>(IExecutable<Unit, T>, Action)

Prepends a parameterless action to the current executable, creating a single synchronous pipeline.

[Pure]
public static IExecutable<Unit, T> Compose<T>(this IExecutable<Unit, T> first, Action second)

Parameters

first IExecutable<Unit, T>

Executable invoked after second.

second Action

Parameterless action invoked first.

Returns

IExecutable<Unit, T>

Executable that runs second and then first.

Type Parameters

T

Exceptions

ArgumentNullException

second is null.

Compose<T1, T2>(IExecutable<Unit, T2>, AsyncAction<T1>)

Prepends an asynchronous action to the current synchronous executable, creating a single asynchronous pipeline.

[Pure]
public static IAsyncExecutable<T1, T2> Compose<T1, T2>(this IExecutable<Unit, T2> first, AsyncAction<T1> second)

Parameters

first IExecutable<Unit, T2>

Synchronous executable invoked after second.

second AsyncAction<T1>

Asynchronous action invoked first.

Returns

IAsyncExecutable<T1, T2>

Asynchronous executable that runs second and then first.

Type Parameters

T1
T2

Exceptions

ArgumentNullException

second is null.

Compose<T1, T2>(IExecutable<Unit, T2>, Action<T1>)

Prepends an action to the current executable, creating a single synchronous pipeline.

[Pure]
public static IExecutable<T1, T2> Compose<T1, T2>(this IExecutable<Unit, T2> first, Action<T1> second)

Parameters

first IExecutable<Unit, T2>

Executable invoked after second.

second Action<T1>

Action invoked first.

Returns

IExecutable<T1, T2>

Executable that runs second and then first.

Type Parameters

T1
T2

Exceptions

ArgumentNullException

second is null.

Compose<T1, T2>(IExecutable<T1, T2>, AsyncFunc<T1>)

Prepends a parameterless asynchronous delegate to the current synchronous executable, creating a single asynchronous pipeline.

[Pure]
public static IAsyncExecutable<Unit, T2> Compose<T1, T2>(this IExecutable<T1, T2> first, AsyncFunc<T1> second)

Parameters

first IExecutable<T1, T2>

Synchronous executable invoked after second.

second AsyncFunc<T1>

Parameterless asynchronous delegate invoked first.

Returns

IAsyncExecutable<Unit, T2>

Asynchronous executable that runs second and then first.

Type Parameters

T1
T2

Exceptions

ArgumentNullException

second is null.

Compose<T1, T2>(IExecutable<T1, T2>, Func<T1>)

Prepends a parameterless delegate to the current executable, creating a single synchronous pipeline.

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

Parameters

first IExecutable<T1, T2>

Executable invoked after second.

second Func<T1>

Parameterless delegate invoked first.

Returns

IExecutable<Unit, T2>

Executable that runs second and then first.

Type Parameters

T1
T2

Exceptions

ArgumentNullException

second is null.

Compose<T1, T2, T3>(IExecutable<T2, T3>, AsyncFunc<T1, T2>)

Prepends an asynchronous delegate to the current synchronous executable, creating a single asynchronous pipeline.

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

Parameters

first IExecutable<T2, T3>

Synchronous executable invoked after second.

second AsyncFunc<T1, T2>

Asynchronous delegate invoked first.

Returns

IAsyncExecutable<T1, T3>

Asynchronous executable that runs second and then first.

Type Parameters

T1
T2
T3

Exceptions

ArgumentNullException

second is null.

Compose<T1, T2, T3>(IExecutable<T2, T3>, IAsyncExecutable<T1, T2>)

Prepends an asynchronous executable to the current synchronous executable, creating a single asynchronous pipeline.

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

Parameters

first IExecutable<T2, T3>

Synchronous executable invoked after second.

second IAsyncExecutable<T1, T2>

Asynchronous executable invoked first.

Returns

IAsyncExecutable<T1, T3>

Asynchronous executable that runs second and then first.

Type Parameters

T1
T2
T3

Exceptions

ArgumentNullException

second is null.

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

Prepends an executable to the current executable, creating a single synchronous pipeline.

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

Parameters

first IExecutable<T2, T3>

Executable invoked after second.

second IExecutable<T1, T2>

Executable invoked first.

Returns

IExecutable<T1, T3>

Executable that runs second and then first.

Type Parameters

T1
T2
T3

Examples

IExecutable<int, string> stringify =
  Executable.Create((int value) => value.ToString());

IExecutable<string, string> pipeline =
  stringify.Compose(Executable.Create((string text) => int.Parse(text)));

Remarks

Compose is the reverse form of Then. It is useful when you already have the later stage and want to prepend an earlier stage in front of it.

Conceptually, first.Compose(second) is equivalent to second.Then(first).

Exceptions

ArgumentNullException

second is null.

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

Prepends a delegate to the current executable, creating a single synchronous pipeline.

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

Parameters

first IExecutable<T2, T3>

Executable invoked after second.

second Func<T1, T2>

Delegate invoked first.

Returns

IExecutable<T1, T3>

Executable that runs second and then first.

Type Parameters

T1
T2
T3

Exceptions

ArgumentNullException

second is null.

Then<T>(IExecutable<T, Unit>, AsyncAction)

Appends a parameterless asynchronous action to the current synchronous executable, creating a single asynchronous pipeline.

[Pure]
public static IAsyncExecutable<T, Unit> Then<T>(this IExecutable<T, Unit> first, AsyncAction second)

Parameters

first IExecutable<T, Unit>

Executable invoked first.

second AsyncAction

Parameterless asynchronous action invoked after first completes.

Returns

IAsyncExecutable<T, Unit>

Asynchronous executable that runs first and then second.

Type Parameters

T

Exceptions

ArgumentNullException

second is null.

Then<T>(IExecutable<T, Unit>, Action)

Appends a parameterless action to the current executable, creating a single synchronous pipeline.

[Pure]
public static IExecutable<T, Unit> Then<T>(this IExecutable<T, Unit> first, Action second)

Parameters

first IExecutable<T, Unit>

Executable invoked first.

second Action

Parameterless action invoked after first completes.

Returns

IExecutable<T, Unit>

Executable that runs first and then second.

Type Parameters

T

Exceptions

ArgumentNullException

second is null.

Then<T1, T2>(IExecutable<T1, Unit>, AsyncFunc<T2>)

Appends a parameterless asynchronous delegate to the current synchronous executable, creating a single asynchronous pipeline.

[Pure]
public static IAsyncExecutable<T1, T2> Then<T1, T2>(this IExecutable<T1, Unit> first, AsyncFunc<T2> second)

Parameters

first IExecutable<T1, Unit>

Executable invoked first.

second AsyncFunc<T2>

Parameterless asynchronous delegate invoked after first completes.

Returns

IAsyncExecutable<T1, T2>

Asynchronous executable that runs first and then second.

Type Parameters

T1
T2

Exceptions

ArgumentNullException

second is null.

Then<T1, T2>(IExecutable<T1, Unit>, Func<T2>)

Appends a parameterless delegate to the current executable, creating a single synchronous pipeline.

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

Parameters

first IExecutable<T1, Unit>

Executable invoked first.

second Func<T2>

Parameterless delegate invoked after first completes.

Returns

IExecutable<T1, T2>

Executable that runs first and then second.

Type Parameters

T1
T2

Exceptions

ArgumentNullException

second is null.

Then<T1, T2>(IExecutable<T1, T2>, AsyncAction<T2>)

Appends an asynchronous action to the current synchronous executable, creating a single asynchronous pipeline.

[Pure]
public static IAsyncExecutable<T1, Unit> Then<T1, T2>(this IExecutable<T1, T2> first, AsyncAction<T2> second)

Parameters

first IExecutable<T1, T2>

Executable invoked first.

second AsyncAction<T2>

Asynchronous action invoked with the result of first.

Returns

IAsyncExecutable<T1, Unit>

Asynchronous executable that runs first and then second.

Type Parameters

T1
T2

Exceptions

ArgumentNullException

second is null.

Then<T1, T2>(IExecutable<T1, T2>, Action<T2>)

Appends an action to the current executable, creating a single synchronous pipeline.

[Pure]
public static IExecutable<T1, Unit> Then<T1, T2>(this IExecutable<T1, T2> first, Action<T2> second)

Parameters

first IExecutable<T1, T2>

Executable invoked first.

second Action<T2>

Action invoked with the result of first.

Returns

IExecutable<T1, Unit>

Executable that runs first and then second.

Type Parameters

T1
T2

Exceptions

ArgumentNullException

second is null.

Then<T1, T2, T3>(IExecutable<T1, T2>, AsyncFunc<T2, T3>)

Appends an asynchronous delegate to the current synchronous executable, creating a single asynchronous pipeline.

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

Parameters

first IExecutable<T1, T2>

Executable invoked first.

second AsyncFunc<T2, T3>

Asynchronous delegate invoked with the result of first.

Returns

IAsyncExecutable<T1, T3>

Asynchronous executable that runs first and then second.

Type Parameters

T1
T2
T3

Exceptions

ArgumentNullException

second is null.

Then<T1, T2, T3>(IExecutable<T1, T2>, IAsyncExecutable<T2, T3>)

Appends an asynchronous executable to the current synchronous executable, creating a single asynchronous pipeline.

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

Parameters

first IExecutable<T1, T2>

Synchronous executable invoked first.

second IAsyncExecutable<T2, T3>

Asynchronous executable invoked with the result of first.

Returns

IAsyncExecutable<T1, T3>

Asynchronous executable that runs first and then second.

Type Parameters

T1
T2
T3

Exceptions

ArgumentNullException

second is null.

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

Appends an executable to the current executable, creating a single synchronous pipeline.

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

Parameters

first IExecutable<T1, T2>

Executable invoked first.

second IExecutable<T2, T3>

Executable invoked with the result of first.

Returns

IExecutable<T1, T3>

Executable that runs first and then second.

Type Parameters

T1
T2
T3

Examples

IExecutable<string, string> pipeline =
  Executable.Create((string text) => int.Parse(text))
    .Then(Executable.Create((int value) => (value * 2).ToString()));

Remarks

Then is the primary left-to-right composition operator for synchronous executables.

Use it when the output contract of the first executable matches the input contract of the second executable.

Exceptions

ArgumentNullException

second is null.

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

Appends a delegate to the current executable, creating a single synchronous pipeline.

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

Parameters

first IExecutable<T1, T2>

Executable invoked first.

second Func<T2, T3>

Delegate invoked with the result of first.

Returns

IExecutable<T1, T3>

Executable that runs first and then second.

Type Parameters

T1
T2
T3

Exceptions

ArgumentNullException

second is null.