예제 #1
0
 /// <summary>
 /// Evaluates a condition on the wrapped value.
 /// </summary>
 /// <typeparam name="TSource">The type of the wrapped value.</typeparam>
 /// <param name="source">The wrapper.</param>
 /// <param name="predicate">A function to test the wrapped value for a condition.</param>
 /// <returns>
 /// <paramref name="source"/> if <paramref name="predicate"/> yields true when evaluated on the wrapped value; a wrapped <see cref="InvalidOperationException"/> otherwise.
 /// </returns>
 public static Try <TSource> Where <TSource>(this Try <TSource> source, Func <TSource, bool> predicate)
 => source.Bind(val => predicate(val) ? source : Try.LiftException <TSource>(new InvalidOperationException("Predicate not satisfied")));
예제 #2
0
 /// <inheritdoc/>
 internal override Try <TResult> Bind <TResult>(Func <T, Try <TResult> > bind)
 => Try.LiftException <TResult>(this.Exception);