Ejemplo n.º 1
0
 /// <summary>
 /// Creates a failed attempt with a result and an exception.
 /// </summary>
 /// <typeparam name="TResult">The type of the attempted operation result.</typeparam>
 /// <param name="result">The result of the attempt.</param>
 /// <param name="exception">The exception causing the failure of the attempt.</param>
 /// <returns>The failed attempt.</returns>
 public static Attempt <TResult?> Fail <TResult>(TResult result, Exception exception)
 {
     return(Attempt <TResult> .Fail(result, exception));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a failed attempt with a result, an exception and a status.
 /// </summary>
 /// <typeparam name="TResult">The type of the attempted operation result.</typeparam>
 /// <typeparam name="TStatus">The type of the attempted operation status.</typeparam>
 /// <param name="status">The status of the attempt.</param>
 /// <param name="result">The result of the attempt.</param>
 /// <param name="exception">The exception causing the failure of the attempt.</param>
 /// <returns>The failed attempt.</returns>
 public static Attempt <TResult, TStatus> FailWithStatus <TResult, TStatus>(TStatus status, TResult result, Exception exception)
 {
     return(Attempt <TResult, TStatus> .Fail(status, result, exception));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a failed attempt with a result.
 /// </summary>
 /// <typeparam name="TResult">The type of the attempted operation result.</typeparam>
 /// <param name="result">The result of the attempt.</param>
 /// <returns>The failed attempt.</returns>
 public static Attempt <TResult?> Fail <TResult>(TResult result)
 {
     return(Attempt <TResult?> .Fail(result));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a failed attempt with a result and a status.
 /// </summary>
 /// <typeparam name="TResult">The type of the attempted operation result.</typeparam>
 /// <typeparam name="TStatus">The type of the attempted operation status.</typeparam>
 /// <param name="status">The status of the attempt.</param>
 /// <param name="result">The result of the attempt.</param>
 /// <returns>The failed attempt.</returns>
 public static Attempt <TResult, TStatus> FailWithStatus <TResult, TStatus>(TStatus status, TResult result)
 {
     return(Attempt <TResult, TStatus> .Fail(status, result));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a failed attempt.
 /// </summary>
 /// <typeparam name="TResult">The type of the attempted operation result.</typeparam>
 /// <returns>The failed attempt.</returns>
 public static Attempt <TResult> Fail <TResult>()
 {
     return(Attempt <TResult> .Fail());
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates a successful attempt with a result and a status.
 /// </summary>
 /// <typeparam name="TResult">The type of the attempted operation result.</typeparam>
 /// <typeparam name="TStatus">The type of the attempted operation status.</typeparam>
 /// <param name="status">The status of the attempt.</param>
 /// <param name="result">The result of the attempt.</param>
 /// <returns>The successful attempt.</returns>
 public static Attempt <TResult, TStatus> SucceedWithStatus <TResult, TStatus>(TStatus status, TResult result)
 {
     return(Attempt <TResult, TStatus> .Succeed(status, result));
 }
Ejemplo n.º 7
0
        // note:
        // cannot rely on overloads only to differentiate between with/without status
        // in some cases it will always be ambiguous, so be explicit w/ 'WithStatus' methods

        /// <summary>
        /// Creates a successful attempt with a result.
        /// </summary>
        /// <typeparam name="TResult">The type of the attempted operation result.</typeparam>
        /// <param name="result">The result of the attempt.</param>
        /// <returns>The successful attempt.</returns>
        public static Attempt <TResult?> Succeed <TResult>(TResult?result)
        {
            return(Attempt <TResult?> .Succeed(result));
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates a successful or a failed attempt, with a result.
 /// </summary>
 /// <typeparam name="TResult">The type of the attempted operation result.</typeparam>
 /// <typeparam name="TStatus">The type of the attempted operation status.</typeparam>
 /// <param name="condition">A value indicating whether the attempt is successful.</param>
 /// <param name="succStatus">The status of the successful attempt.</param>
 /// <param name="failStatus">The status of the failed attempt.</param>
 /// <param name="result">The result of the attempt.</param>
 /// <returns>The attempt.</returns>
 public static Attempt <TResult, TStatus> IfWithStatus <TResult, TStatus>(bool condition, TStatus succStatus, TStatus failStatus, TResult result)
 {
     return(Attempt <TResult, TStatus> .If(condition, succStatus, failStatus, result));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Creates a successful or a failed attempt, with a result.
 /// </summary>
 /// <typeparam name="TResult">The type of the attempted operation result.</typeparam>
 /// <param name="condition">A value indicating whether the attempt is successful.</param>
 /// <param name="result">The result of the attempt.</param>
 /// <returns>The attempt.</returns>
 public static Attempt <TResult> If <TResult>(bool condition, TResult result)
 {
     return(Attempt <TResult> .If(condition, result));
 }