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
firstIExecutable<Unit, T>Synchronous executable invoked after
second.secondAsyncActionParameterless asynchronous action invoked first.
Returns
- IAsyncExecutable<Unit, T>
Asynchronous executable that runs
secondand thenfirst.
Type Parameters
T
Exceptions
- ArgumentNullException
secondis 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
firstIExecutable<Unit, T>Executable invoked after
second.secondActionParameterless action invoked first.
Returns
- IExecutable<Unit, T>
Executable that runs
secondand thenfirst.
Type Parameters
T
Exceptions
- ArgumentNullException
secondis 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
firstIExecutable<Unit, T2>Synchronous executable invoked after
second.secondAsyncAction<T1>Asynchronous action invoked first.
Returns
- IAsyncExecutable<T1, T2>
Asynchronous executable that runs
secondand thenfirst.
Type Parameters
T1T2
Exceptions
- ArgumentNullException
secondis 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
firstIExecutable<Unit, T2>Executable invoked after
second.secondAction<T1>Action invoked first.
Returns
- IExecutable<T1, T2>
Executable that runs
secondand thenfirst.
Type Parameters
T1T2
Exceptions
- ArgumentNullException
secondis 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
firstIExecutable<T1, T2>Synchronous executable invoked after
second.secondAsyncFunc<T1>Parameterless asynchronous delegate invoked first.
Returns
- IAsyncExecutable<Unit, T2>
Asynchronous executable that runs
secondand thenfirst.
Type Parameters
T1T2
Exceptions
- ArgumentNullException
secondis 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
firstIExecutable<T1, T2>Executable invoked after
second.secondFunc<T1>Parameterless delegate invoked first.
Returns
- IExecutable<Unit, T2>
Executable that runs
secondand thenfirst.
Type Parameters
T1T2
Exceptions
- ArgumentNullException
secondis 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
firstIExecutable<T2, T3>Synchronous executable invoked after
second.secondAsyncFunc<T1, T2>Asynchronous delegate invoked first.
Returns
- IAsyncExecutable<T1, T3>
Asynchronous executable that runs
secondand thenfirst.
Type Parameters
T1T2T3
Exceptions
- ArgumentNullException
secondis 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
firstIExecutable<T2, T3>Synchronous executable invoked after
second.secondIAsyncExecutable<T1, T2>Asynchronous executable invoked first.
Returns
- IAsyncExecutable<T1, T3>
Asynchronous executable that runs
secondand thenfirst.
Type Parameters
T1T2T3
Exceptions
- ArgumentNullException
secondis 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
firstIExecutable<T2, T3>Executable invoked after
second.secondIExecutable<T1, T2>Executable invoked first.
Returns
- IExecutable<T1, T3>
Executable that runs
secondand thenfirst.
Type Parameters
T1T2T3
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
secondis 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
firstIExecutable<T2, T3>Executable invoked after
second.secondFunc<T1, T2>Delegate invoked first.
Returns
- IExecutable<T1, T3>
Executable that runs
secondand thenfirst.
Type Parameters
T1T2T3
Exceptions
- ArgumentNullException
secondis 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
firstIExecutable<T, Unit>Executable invoked first.
secondAsyncActionParameterless asynchronous action invoked after
firstcompletes.
Returns
- IAsyncExecutable<T, Unit>
Asynchronous executable that runs
firstand thensecond.
Type Parameters
T
Exceptions
- ArgumentNullException
secondis 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
firstIExecutable<T, Unit>Executable invoked first.
secondActionParameterless action invoked after
firstcompletes.
Returns
- IExecutable<T, Unit>
Executable that runs
firstand thensecond.
Type Parameters
T
Exceptions
- ArgumentNullException
secondis 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
firstIExecutable<T1, Unit>Executable invoked first.
secondAsyncFunc<T2>Parameterless asynchronous delegate invoked after
firstcompletes.
Returns
- IAsyncExecutable<T1, T2>
Asynchronous executable that runs
firstand thensecond.
Type Parameters
T1T2
Exceptions
- ArgumentNullException
secondis 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
firstIExecutable<T1, Unit>Executable invoked first.
secondFunc<T2>Parameterless delegate invoked after
firstcompletes.
Returns
- IExecutable<T1, T2>
Executable that runs
firstand thensecond.
Type Parameters
T1T2
Exceptions
- ArgumentNullException
secondis 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
firstIExecutable<T1, T2>Executable invoked first.
secondAsyncAction<T2>Asynchronous action invoked with the result of
first.
Returns
- IAsyncExecutable<T1, Unit>
Asynchronous executable that runs
firstand thensecond.
Type Parameters
T1T2
Exceptions
- ArgumentNullException
secondis 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
firstIExecutable<T1, T2>Executable invoked first.
secondAction<T2>Action invoked with the result of
first.
Returns
- IExecutable<T1, Unit>
Executable that runs
firstand thensecond.
Type Parameters
T1T2
Exceptions
- ArgumentNullException
secondis 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
firstIExecutable<T1, T2>Executable invoked first.
secondAsyncFunc<T2, T3>Asynchronous delegate invoked with the result of
first.
Returns
- IAsyncExecutable<T1, T3>
Asynchronous executable that runs
firstand thensecond.
Type Parameters
T1T2T3
Exceptions
- ArgumentNullException
secondis 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
firstIExecutable<T1, T2>Synchronous executable invoked first.
secondIAsyncExecutable<T2, T3>Asynchronous executable invoked with the result of
first.
Returns
- IAsyncExecutable<T1, T3>
Asynchronous executable that runs
firstand thensecond.
Type Parameters
T1T2T3
Exceptions
- ArgumentNullException
secondis 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
firstIExecutable<T1, T2>Executable invoked first.
secondIExecutable<T2, T3>Executable invoked with the result of
first.
Returns
- IExecutable<T1, T3>
Executable that runs
firstand thensecond.
Type Parameters
T1T2T3
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
secondis 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
firstIExecutable<T1, T2>Executable invoked first.
secondFunc<T2, T3>Delegate invoked with the result of
first.
Returns
- IExecutable<T1, T3>
Executable that runs
firstand thensecond.
Type Parameters
T1T2T3
Exceptions
- ArgumentNullException
secondis null.