Пример #1
0
 /// <summary>
 /// 根据结果创建一个成功或失败的尝试.
 /// </summary>
 /// <typeparam name="T">尝试操作结果的类型.</typeparam>
 /// <param name="success">一个值,该值指示是否成功.</param>
 /// <param name="result">尝试的结果.</param>
 /// <returns>The attempt.</returns>
 public static Attempt <T> If <T>(bool success, T result)
 {
     return(Attempt <T> .SucceedIf(success, result));
 }
Пример #2
0
 /// <summary>
 /// 创建失败的尝试结果.
 /// </summary>
 /// <typeparam name="T">尝试操作结果的类型.</typeparam>
 /// <param name="result">尝试的结果.</param>
 /// <returns>The failed attempt.</returns>
 public static Attempt <T> Fail <T>(T result)
 {
     return(Attempt <T> .Fail(result));
 }
Пример #3
0
 /// <summary>
 /// 创建失败的尝试结果和异常.
 /// </summary>
 /// <typeparam name="T">尝试操作结果的类型.</typeparam>
 /// <param name="result">尝试的结果.</param>
 /// <param name="exception">尝试的失败造成的异常.</param>
 /// <returns>The failed attempt.</returns>
 public static Attempt <T> Fail <T>(T result, Exception exception)
 {
     return(Attempt <T> .Fail(result, exception));
 }
Пример #4
0
 /// <summary>
 /// 创造一个成功的尝试,结果。
 /// </summary>
 /// <typeparam name="T">尝试操作结果的类型.</typeparam>
 /// <param name="result">尝试的结果.</param>
 /// <returns>成功的尝试.</returns>
 public static Attempt <T> Succeed <T>(T result)
 {
     return(Attempt <T> .Succeed(result));
 }