/// <summary> /// Repeatedly yields a lazy invocation attempt of the factory as an enumerable. /// </summary> /// <param name="default">The result value when not successful.</param> public static IEnumerable <Lazy <Task <Attempt <T> > > > GetAsync <T>(Func <Task <T> > factory, T @default = default(T)) { while (true) { yield return(new Lazy <Task <Attempt <T> > >(() => Attempt.GetAsync(factory, @default))); } }
/// <summary> /// Invokes the factory, using the source as input, suppressing any thrown exception. /// </summary> /// <param name="default">The result value when not successful.</param> public static Task <Attempt <TResult> > AttemptGetAsync <TSource, TResult>(this TSource source, Func <TSource, Task <TResult> > factory, TResult @default = default(TResult)) { return(Attempt.GetAsync(() => factory(source))); }