コード例 #1
0
ファイル: OperationResult.cs プロジェクト: yalerok10/results
 /// <summary>
 /// Applies the <c>bindAsync</c> asynchronous function to the message of the operation result produced by the given task if it doesn't match as a success.
 /// Otherwise the operation result is passed on with the appropriate expected value type.
 /// </summary>
 /// <param name="source">The task producing the operation result to be processed.</param>
 /// <param name="bindAsync">The asynchronous function to be applied to the source result error message if it matches as an error or to the exception message if it matches as a failure.</param>
 /// <param name="getFailureMessage">A function used to extract the exception message from the result if it matches as a failure.</param>
 /// <typeparam name="T">The expected type of the source result value.</typeparam>
 /// <returns>A task producing a new operation result calculated based on the matching of the source result.</returns>
 public static async Task <IOperationResult <T> > BindErrorAsync <T>(this IOperationResult <T> source, Func <string, Task <IOperationResult <T> > > bindAsync, Func <Exception, string> getFailureMessage)
 {
     return(await source.BindErrorAsync((_, error) => bindAsync(error), getFailureMessage));
 }