public static IAsyncOptionEnumerable <TResult> SelectMany <TSuccess, TBind, TResult>(this IAsyncOptionEnumerable <TSuccess> source, Func <TSuccess, Option <TBind> > bind, Func <TSuccess, TBind, TResult> resultSelector) where TSuccess : notnull where TBind : notnull where TResult : notnull { if (bind == null) { throw new ArgumentNullException(nameof(bind)); } if (resultSelector == null) { throw new ArgumentNullException(nameof(resultSelector)); } return(source .Select(result => result .Match(success => bind .Invoke(success) .Map(value => resultSelector.Invoke(success, value)), Option.None <TResult> ) ) .AsAsyncOptionEnumerable()); }
public static IAsyncOptionEnumerable <TValue> Where <TValue>(this IAsyncOptionEnumerable <TValue> source, Func <TValue, Option <Unit> > failurePredicate) => source .Select(value => value .Bind(success => failurePredicate .Invoke(success) .Map(_ => success) ) ) .AsAsyncOptionEnumerable();
public static IAsyncOptionEnumerable <TResult> Select <TSuccess, TResult>(this IAsyncOptionEnumerable <TSuccess> source, Func <TSuccess, TResult> selector) { if (selector == null) { throw new ArgumentNullException(nameof(selector)); } return(source .Select(result => result .Match( success => Option.Some(selector.Invoke(success)), Option.None <TResult> ) ) .AsAsyncOptionEnumerable()); }