Class AsyncExecutableExtensions
- Namespace
- Executables
- Assembly
- executables.dll
Extension methods for composing and adapting asynchronous executables.
public static class AsyncExecutableExtensions
- Inheritance
-
AsyncExecutableExtensions
- Inherited Members
Methods
Accumulate<T1, T2, T3>(IAsyncExecutable<T1, T2>, AsyncFunc<T2, T3>)
Appends an asynchronous projection while preserving the previous result in the returned tuple.
[Pure]
public static IAsyncExecutable<T1, (T2, T3)> Accumulate<T1, T2, T3>(this IAsyncExecutable<T1, T2> first, AsyncFunc<T2, T3> second)
Parameters
firstIAsyncExecutable<T1, T2>Executable that produces the value passed to
second.secondAsyncFunc<T2, T3>Asynchronous delegate that computes an additional value from the result of
first.
Returns
- IAsyncExecutable<T1, (T2, T3)>
Asynchronous executable that returns both the original result and the appended value.
Type Parameters
T1T2T3
Exceptions
- ArgumentNullException
secondis null.
Accumulate<T1, T2, T3, T4>(IAsyncExecutable<T1, (T2, T3)>, AsyncFunc<T2, T3, T4>)
Appends an asynchronous projection while preserving the accumulated tuple produced by the previous stage.
[Pure]
public static IAsyncExecutable<T1, (T2, T3, T4)> Accumulate<T1, T2, T3, T4>(this IAsyncExecutable<T1, (T2, T3)> first, AsyncFunc<T2, T3, T4> second)
Parameters
firstIAsyncExecutable<T1, (T2, T3)>Executable that produces the tuple passed to
second.secondAsyncFunc<T2, T3, T4>Asynchronous delegate that computes an additional value from the accumulated tuple items.
Returns
- IAsyncExecutable<T1, (T2, T3, T4)>
Asynchronous executable that returns the original tuple items plus the appended value.
Type Parameters
T1T2T3T4
Exceptions
- ArgumentNullException
secondis null.
Accumulate<T1, T2, T3, T4, T5>(IAsyncExecutable<T1, (T2, T3, T4)>, AsyncFunc<T2, T3, T4, T5>)
Appends an asynchronous projection while preserving the accumulated tuple produced by the previous stage.
[Pure]
public static IAsyncExecutable<T1, (T2, T3, T4, T5)> Accumulate<T1, T2, T3, T4, T5>(this IAsyncExecutable<T1, (T2, T3, T4)> first, AsyncFunc<T2, T3, T4, T5> second)
Parameters
firstIAsyncExecutable<T1, (T2, T3, T4)>Executable that produces the tuple passed to
second.secondAsyncFunc<T2, T3, T4, T5>Asynchronous delegate that computes an additional value from the accumulated tuple items.
Returns
- IAsyncExecutable<T1, (T2, T3, T4, T5)>
Asynchronous executable that returns the original tuple items plus the appended value.
Type Parameters
T1T2T3T4T5
Exceptions
- ArgumentNullException
secondis null.
AsCommand<T>(IAsyncCommand<T>)
Returns the same asynchronous command instance.
[Pure]
public static IAsyncCommand<T> AsCommand<T>(this IAsyncCommand<T> command)
Parameters
commandIAsyncCommand<T>
Returns
- IAsyncCommand<T>
The original async command.
Type Parameters
T
AsCommand<T>(IAsyncExecutable<T, bool>)
Converts an asynchronous executable to an asynchronous command.
[Pure]
public static IAsyncCommand<T> AsCommand<T>(this IAsyncExecutable<T, bool> executable)
Parameters
executableIAsyncExecutable<T, bool>
Returns
- IAsyncCommand<T>
Async command wrapping the executable.
Type Parameters
T
AsExecutable<T1, T2>(IAsyncExecutable<T1, T2>)
Returns the same asynchronous executable instance.
[Pure]
public static IAsyncExecutable<T1, T2> AsExecutable<T1, T2>(this IAsyncExecutable<T1, T2> executable)
Parameters
executableIAsyncExecutable<T1, T2>
Returns
- IAsyncExecutable<T1, T2>
Type Parameters
T1T2
AsHandler<T1, T2>(AsyncHandler<T1, T2>)
Returns the same asynchronous handler instance.
[Pure]
public static AsyncHandler<T1, T2> AsHandler<T1, T2>(this AsyncHandler<T1, T2> handler)
Parameters
handlerAsyncHandler<T1, T2>
Returns
- AsyncHandler<T1, T2>
The original async handler.
Type Parameters
T1T2
AsHandler<T1, T2>(IAsyncExecutable<T1, T2>)
Converts an asynchronous executable to an asynchronous handler.
[Pure]
public static AsyncHandler<T1, T2> AsHandler<T1, T2>(this IAsyncExecutable<T1, T2> executable)
Parameters
executableIAsyncExecutable<T1, T2>
Returns
- AsyncHandler<T1, T2>
Async handler wrapping the executable.
Type Parameters
T1T2
AsQuery<T1, T2>(IAsyncExecutable<T1, T2>)
Converts an asynchronous executable to an asynchronous query.
[Pure]
public static IAsyncQuery<T1, T2> AsQuery<T1, T2>(this IAsyncExecutable<T1, T2> executable)
Parameters
executableIAsyncExecutable<T1, T2>
Returns
- IAsyncQuery<T1, T2>
Async query wrapping the executable.
Type Parameters
T1T2
AsQuery<T1, T2>(IAsyncQuery<T1, T2>)
Returns the same asynchronous query instance.
[Pure]
public static IAsyncQuery<T1, T2> AsQuery<T1, T2>(this IAsyncQuery<T1, T2> query)
Parameters
queryIAsyncQuery<T1, T2>
Returns
- IAsyncQuery<T1, T2>
The original async query.
Type Parameters
T1T2
First<T1, T2, T3, TNew>(IAsyncExecutable<T1, (T2, T3)>, AsyncFunc<T2, TNew>)
Maps the first item of a tuple result with an asynchronous delegate.
[Pure]
public static IAsyncExecutable<T1, (TNew, T3)> First<T1, T2, T3, TNew>(this IAsyncExecutable<T1, (T2, T3)> fork, AsyncFunc<T2, TNew> map)
Parameters
forkIAsyncExecutable<T1, (T2, T3)>Executable that returns a tuple.
mapAsyncFunc<T2, TNew>Delegate applied to the first tuple item.
Returns
- IAsyncExecutable<T1, (TNew, T3)>
Executable with transformed first tuple item.
Type Parameters
T1T2T3TNew
Exceptions
- ArgumentNullException
mapis null.
First<T1, T2, T3, TNew>(IAsyncExecutable<T1, (T2, T3)>, IAsyncExecutable<T2, TNew>)
Maps the first item of a tuple result.
[Pure]
public static IAsyncExecutable<T1, (TNew, T3)> First<T1, T2, T3, TNew>(this IAsyncExecutable<T1, (T2, T3)> fork, IAsyncExecutable<T2, TNew> map)
Parameters
forkIAsyncExecutable<T1, (T2, T3)>Executable that returns a tuple.
mapIAsyncExecutable<T2, TNew>Executable applied to the first tuple item.
Returns
- IAsyncExecutable<T1, (TNew, T3)>
Executable with transformed first tuple item.
Type Parameters
T1T2T3TNew
Exceptions
- ArgumentNullException
mapis null.
FlatMap<T1, T2, T3>(IAsyncExecutable<T1, T2>, AsyncFunc<T2, IAsyncExecutable<T2, T3>>)
Chains an asynchronous executable with an asynchronous delegate that selects the next executable to run and flattens the nested result.
[Pure]
public static IAsyncExecutable<T1, T3> FlatMap<T1, T2, T3>(this IAsyncExecutable<T1, T2> first, AsyncFunc<T2, IAsyncExecutable<T2, T3>> second)
Parameters
firstIAsyncExecutable<T1, T2>Executable invoked first.
secondAsyncFunc<T2, IAsyncExecutable<T2, T3>>Delegate that receives the result of
firstand returns the next executable to run.
Returns
- IAsyncExecutable<T1, T3>
Asynchronous executable that executes both stages as a single pipeline.
Type Parameters
T1T2T3
Exceptions
- ArgumentNullException
secondis null.
FlatMap<T1, T2, T3>(IAsyncExecutable<T1, T2>, IAsyncExecutable<T2, IAsyncExecutable<T2, T3>>)
Chains an asynchronous executable with another executable-producing asynchronous executable and flattens the nested result.
[Pure]
public static IAsyncExecutable<T1, T3> FlatMap<T1, T2, T3>(this IAsyncExecutable<T1, T2> first, IAsyncExecutable<T2, IAsyncExecutable<T2, T3>> second)
Parameters
firstIAsyncExecutable<T1, T2>Executable invoked first.
secondIAsyncExecutable<T2, IAsyncExecutable<T2, T3>>Executable that receives the result of
firstand returns the next executable to run.
Returns
- IAsyncExecutable<T1, T3>
Asynchronous executable that executes both stages as a single pipeline.
Type Parameters
T1T2T3
Exceptions
- ArgumentNullException
secondis null.
FlatMap<T1, T2, T3>(IAsyncExecutable<T1, T2>, Func<T2, IAsyncExecutable<T2, T3>>)
Chains an asynchronous executable with a delegate that selects the next executable to run and flattens the nested result.
[Pure]
public static IAsyncExecutable<T1, T3> FlatMap<T1, T2, T3>(this IAsyncExecutable<T1, T2> first, Func<T2, IAsyncExecutable<T2, T3>> second)
Parameters
firstIAsyncExecutable<T1, T2>Executable invoked first.
secondFunc<T2, IAsyncExecutable<T2, T3>>Delegate that receives the result of
firstand returns the next executable to run.
Returns
- IAsyncExecutable<T1, T3>
Asynchronous executable that executes both stages as a single pipeline.
Type Parameters
T1T2T3
Exceptions
- ArgumentNullException
secondis null.
Fork<T1, T2, T3, T4>(IAsyncExecutable<T1, T2>, AsyncFunc<T2, T3>, AsyncFunc<T2, T4>)
Branches asynchronous execution into two asynchronous delegates and returns both results.
[Pure]
public static IAsyncExecutable<T1, (T3, T4)> Fork<T1, T2, T3, T4>(this IAsyncExecutable<T1, T2> executable, AsyncFunc<T2, T3> firstBranch, AsyncFunc<T2, T4> secondBranch)
Parameters
executableIAsyncExecutable<T1, T2>Executable that produces the shared branch input.
firstBranchAsyncFunc<T2, T3>First branch delegate.
secondBranchAsyncFunc<T2, T4>Second branch delegate.
Returns
- IAsyncExecutable<T1, (T3, T4)>
Executable that returns both branch results.
Type Parameters
T1T2T3T4
Exceptions
- ArgumentNullException
firstBranchorsecondBranchis null.
Fork<T1, T2, T3, T4>(IAsyncExecutable<T1, T2>, IAsyncExecutable<T2, T3>, IAsyncExecutable<T2, T4>)
Branches asynchronous execution into two asynchronous executables and returns both results.
[Pure]
public static IAsyncExecutable<T1, (T3, T4)> Fork<T1, T2, T3, T4>(this IAsyncExecutable<T1, T2> executable, IAsyncExecutable<T2, T3> firstBranch, IAsyncExecutable<T2, T4> secondBranch)
Parameters
executableIAsyncExecutable<T1, T2>Executable that produces the shared branch input.
firstBranchIAsyncExecutable<T2, T3>First branch executable.
secondBranchIAsyncExecutable<T2, T4>Second branch executable.
Returns
- IAsyncExecutable<T1, (T3, T4)>
Executable that returns both branch results.
Type Parameters
T1T2T3T4
Exceptions
- ArgumentNullException
firstBranchorsecondBranchis null.
MapIso<T1, T2>(IAsyncExecutable<T2, T2>, IIso<T1, T2>)
Adapts an asynchronous endomorphism through an isomorphism.
[Pure]
public static IAsyncExecutable<T1, T1> MapIso<T1, T2>(this IAsyncExecutable<T2, T2> executable, IIso<T1, T2> iso)
Parameters
executableIAsyncExecutable<T2, T2>Asynchronous executable that transforms values of type
T2.isoIIso<T1, T2>Isomorphism used to convert values into and out of
T2.
Returns
- IAsyncExecutable<T1, T1>
Asynchronous executable that transforms values of type
T1by mapping throughiso.
Type Parameters
T1External input and output type.
T2Internal input and output type of the executable.
Map<T1, T2, T3, T4>(IAsyncExecutable<T2, T3>, Func<T1, T2>, Func<T3, T4>)
Adapts an asynchronous executable to different external input and output types by applying delegate mappings around it.
[Pure]
public static IAsyncExecutable<T1, T4> Map<T1, T2, T3, T4>(this IAsyncExecutable<T2, T3> executable, Func<T1, T2> incoming, Func<T3, T4> outgoing)
Parameters
executableIAsyncExecutable<T2, T3>Asynchronous executable being adapted.
incomingFunc<T1, T2>Delegate that converts external input to the executable input type.
outgoingFunc<T3, T4>Delegate that converts executable output to the external output type.
Returns
- IAsyncExecutable<T1, T4>
Asynchronous executable with adapted input and output contracts.
Type Parameters
T1T2T3T4
Exceptions
- ArgumentNullException
incomingoroutgoingis null.
Merge<T1, T2, T3, T4>(IAsyncExecutable<T1, (T2, T3)>, Func<T2, T3, T4>)
Merges a tuple result with a delegate.
[Pure]
public static IAsyncExecutable<T1, T4> Merge<T1, T2, T3, T4>(this IAsyncExecutable<T1, (T2, T3)> fork, Func<T2, T3, T4> merge)
Parameters
forkIAsyncExecutable<T1, (T2, T3)>Executable that returns a tuple.
mergeFunc<T2, T3, T4>Delegate that combines tuple items into a single result.
Returns
- IAsyncExecutable<T1, T4>
Executable that returns the merged result.
Type Parameters
T1T2T3T4
Exceptions
- ArgumentNullException
mergeis null.
Merge<T1, T2, T3, T4, T5>(IAsyncExecutable<T1, (T2, T3, T4)>, Func<T2, T3, T4, T5>)
Merges a three-item tuple result with a delegate.
[Pure]
public static IAsyncExecutable<T1, T5> Merge<T1, T2, T3, T4, T5>(this IAsyncExecutable<T1, (T2, T3, T4)> executable, Func<T2, T3, T4, T5> merge)
Parameters
executableIAsyncExecutable<T1, (T2, T3, T4)>Executable that returns a three-item tuple.
mergeFunc<T2, T3, T4, T5>Delegate that combines tuple items into a single result.
Returns
- IAsyncExecutable<T1, T5>
Asynchronous executable that returns the merged result.
Type Parameters
T1T2T3T4T5
Exceptions
- ArgumentNullException
mergeis null.
Merge<T1, T2, T3, T4, T5, T6>(IAsyncExecutable<T1, (T2, T3, T4, T5)>, Func<T2, T3, T4, T5, T6>)
Merges a four-item tuple result with a delegate.
[Pure]
public static IAsyncExecutable<T1, T6> Merge<T1, T2, T3, T4, T5, T6>(this IAsyncExecutable<T1, (T2, T3, T4, T5)> executable, Func<T2, T3, T4, T5, T6> merge)
Parameters
executableIAsyncExecutable<T1, (T2, T3, T4, T5)>Executable that returns a four-item tuple.
mergeFunc<T2, T3, T4, T5, T6>Delegate that combines tuple items into a single result.
Returns
- IAsyncExecutable<T1, T6>
Asynchronous executable that returns the merged result.
Type Parameters
T1T2T3T4T5T6
Exceptions
- ArgumentNullException
mergeis null.
Second<T1, T2, T3, TNew>(IAsyncExecutable<T1, (T2, T3)>, AsyncFunc<T3, TNew>)
Maps the second item of a tuple result with an asynchronous delegate.
[Pure]
public static IAsyncExecutable<T1, (T2, TNew)> Second<T1, T2, T3, TNew>(this IAsyncExecutable<T1, (T2, T3)> fork, AsyncFunc<T3, TNew> map)
Parameters
forkIAsyncExecutable<T1, (T2, T3)>Executable that returns a tuple.
mapAsyncFunc<T3, TNew>Delegate applied to the second tuple item.
Returns
- IAsyncExecutable<T1, (T2, TNew)>
Executable with transformed second tuple item.
Type Parameters
T1T2T3TNew
Exceptions
- ArgumentNullException
mapis null.
Second<T1, T2, T3, TNew>(IAsyncExecutable<T1, (T2, T3)>, IAsyncExecutable<T3, TNew>)
Maps the second item of a tuple result.
[Pure]
public static IAsyncExecutable<T1, (T2, TNew)> Second<T1, T2, T3, TNew>(this IAsyncExecutable<T1, (T2, T3)> fork, IAsyncExecutable<T3, TNew> map)
Parameters
forkIAsyncExecutable<T1, (T2, T3)>Executable that returns a tuple.
mapIAsyncExecutable<T3, TNew>Executable applied to the second tuple item.
Returns
- IAsyncExecutable<T1, (T2, TNew)>
Executable with transformed second tuple item.
Type Parameters
T1T2T3TNew
Exceptions
- ArgumentNullException
mapis null.
Swap<T1, T2, T3>(IAsyncExecutable<T1, (T2, T3)>)
Swaps items in a tuple result.
[Pure]
public static IAsyncExecutable<T1, (T3, T2)> Swap<T1, T2, T3>(this IAsyncExecutable<T1, (T2, T3)> fork)
Parameters
forkIAsyncExecutable<T1, (T2, T3)>Executable that returns a tuple.
Returns
- IAsyncExecutable<T1, (T3, T2)>
Executable that returns the tuple with reversed item order.
Type Parameters
T1T2T3