示例#1
0
        public static async Task ReportAsync()
        {
            var value = Result.Success(1);

            IResult <int> four = await value
                                 .Map(Calculator.AddOne)
                                 .MapAsync(Calculator.SquareAsync);

            await four.BindAsync(i => CsvFile.TryWriteLineAsync($"The answer is: {i}"));
        }
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="TDisposable"></typeparam>
 /// <typeparam name="TResult"></typeparam>
 /// <param name="this"></param>
 /// <param name="functionResultAsync"></param>
 /// <returns></returns>
 public static Task <IResult <TResult> > UsingResultAsync <TDisposable, TResult>(this IResult <TDisposable> @this,
                                                                                 Func <TDisposable, Task <IResult <TResult> > > functionResultAsync) where TDisposable : IDisposable =>
 @this
 .BindAsync(disposable => disposable.UsingAsync(functionResultAsync));
示例#3
0
 public async Task Bind_WhenFirstEndWithSuccessAsync() =>
 (await firstSuccessResult.BindAsync(() => secondResultAsync)).Map(x => x, _ => throw new Exception("error")).ShouldBe(second);
示例#4
0
 public static Task <IResult <TNext> > BindAnyAsync <TPrev, TNext>(this IResult <TPrev> prev, Func <TPrev, Task <TNext> > next) =>
 prev.BindAsync(a => next(a).AsResultAsync());