Exemple #1
0
 /// <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 <Attempt <T> > > Get <T>(Func <T> factory, T @default = default(T))
 {
     while (true)
     {
         yield return(new Lazy <Attempt <T> >(() => Attempt.Get(factory, @default)));
     }
 }
Exemple #2
0
 /// <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 Attempt <TResult> AttemptGet <TSource, TResult>(this TSource source, Func <TSource, TResult> factory,
                                                               TResult @default = default(TResult))
 {
     return(Attempt.Get(() => factory(source)));
 }