Example #1
0
 public static OperationStatus GetStatus(this ResultBase resultBase)
 {
     if (resultBase.IsCriticalFailure)
     {
         return(OperationStatus.CriticalFailure);
     }
     else if (resultBase.IsCancelled)
     {
         return(OperationStatus.Cancelled);
     }
     else if (!resultBase.Succeeded)
     {
         return(OperationStatus.Failure);
     }
     else
     {
         return(OperationStatus.Success);
     }
 }
 /// <nodoc />
 private static string GetErrorMessage(ResultBase error)
 {
     Contract.Requires(!error.Succeeded);
     Contract.Requires(error.Error != null);
     return(error.Error.ErrorMessage);
 }
Example #3
0
 public FileExistenceResult(ResultCode code, ResultBase other, string?message = null)
     : base(other, message)
 {
     Code = code;
 }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BoolResult" /> class.
 /// </summary>
 public BoolResult(ResultBase other, string?message = null)
     : base(other, message)
 {
 }
Example #5
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="OpenStreamResult" /> class.
 /// </summary>
 public OpenStreamResult(ResultBase other, ResultCode code, string?message = null)
     : base(other, message)
 {
     Code = code;
 }
Example #6
0
 /// <summary>
 /// Special method to ignore potentially not successful result of an operation explicitly.
 /// </summary>
 public static void IgnoreFailure(this ResultBase result)
 {
 }
Example #7
0
 /// <inheritdoc />
 protected override bool SuccessEquals(ResultBase other)
 {
     return(Code == ((PlaceFileResult)other).Code);
 }
Example #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CopyFileResult"/> class.
 /// </summary>
 public CopyFileResult(ResultCode code, ResultBase other, string message = null)
     : base(other, message)
 {
     Code = code;
 }
Example #9
0
 public GetStatsResult(ResultBase other, string?message = null)
     : base(other, message)
 {
 }
Example #10
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="PutResult" /> class.
 /// </summary>
 public PutResult(ResultBase other, string message = null)
     : base(other, message)
 {
 }
Example #11
0
 /// <inheritdoc />
 public Result(ResultBase other, string?message = null)
     : base(other, message)
 {
     _result = default;
 }
Example #12
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="CreateSessionResult{T}"/> class.
 /// </summary>
 public CreateSessionResult(ResultBase other, string message = null)
     : base(other, message)
 {
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="DistributedDeleteResult"/> class.
 /// </summary>
 public DistributedDeleteResult(ResultBase other, string message)
     : base(other, message)
 {
     DeleteMapping = new Dictionary <string, DeleteResult>();
 }
Example #14
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="ErrorResult" /> class.
 /// </summary>
 public ErrorResult(ResultBase other, string?message = null)
     : base(other, message)
 {
     Message = message;
 }
Example #15
0
 /// <summary>
 /// Returns true if the error is critical.
 /// </summary>
 public bool IsCritical(bool isCanceled) => isCanceled?ResultBase.IsCriticalForCancellation(Exception) : ResultBase.IsCritical(Exception);
Example #16
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="OpenStreamResult" /> class.
 /// </summary>
 public OpenStreamResult(ResultBase other, string message = null)
     : base(other, message)
 {
     Code = ResultCode.Error;
 }
Example #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CopyFileResult"/> class.
 /// </summary>
 public CopyFileResult(ResultBase other, string message = null)
     : this(ResultCode.Unknown, other, message)
 {
 }
Example #18
0
 public PutResult(ResultBase other, ContentHash contentHash, string?message = null)
     : base(other, message)
 {
     ContentHash = contentHash;
 }
Example #19
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="PlaceFileResult" /> class.
 /// </summary>
 public PlaceFileResult(ResultBase other, ResultCode code, string?message = null)
     : base(other, message)
 {
     Contract.Requires(code >= ResultCode.Error);
     Code = code;
 }
Example #20
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="CreateSessionResult{T}"/> class.
 /// </summary>
 public CreateSessionResult(ResultBase other, string?message = null)
     : base(other, message)
 {
     Session = default;
 }
Example #21
0
 /// <summary>
 /// Check if equal to another.
 /// </summary>
 protected bool EqualsBase(ResultBase other)
 {
     return(!(other is null) && ErrorMessage == other.ErrorMessage);
 }
Example #22
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="PlaceFileResult" /> class.
 /// </summary>
 public PlaceFileResult(ResultBase other, string message = null)
     : base(other, message)
 {
     Code = ResultCode.Error;
 }
Example #23
0
 /// <nodoc />
 public DeleteResult(ResultBase other, string message)
     : base(other, message)
 {
     Code = ResultCode.Error;
 }
Example #24
0
        /// <inheritdoc />
        protected override bool SuccessEquals(ResultBase other)
        {
            var rhs = (OpenStreamResult)other;

            return(Code == rhs.Code && Stream == rhs.Stream);
        }
Example #25
0
 /// <nodoc />
 public static Result <T> FromError <T>(ResultBase other)
 {
     Contract.Requires(!other.Succeeded);
     return(new Result <T>(other));
 }
Example #26
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="OpenStreamResult" /> class.
 /// </summary>
 public OpenStreamResult(ResultBase other, ResultCode code, string?message = null)
     : base(other, message)
 {
     Contract.Requires(code != ResultCode.Success);
     Code = code;
 }
Example #27
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="PinResult"/> class.
 /// </summary>
 public PinResult(ResultBase other, string?message = null)
     : base(other, message)
 {
     Code = ResultCode.Error;
 }
Example #28
0
 public PlaceFileResult(ResultBase other, ResultCode code, string?message = null)
     : base(other, message)
 {
     Code = code;
 }
Example #29
0
 public FileExistenceResult(ResultBase other, string?message = null)
     : base(other, message)
 {
     Code = ResultCode.Error;
 }
Example #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CopyFileResult"/> class.
 /// </summary>
 public CopyFileResult(CopyResultCode code, ResultBase other, string?message = null)
     : base(other, message)
 {
     Contract.Requires(code != CopyResultCode.Success);
     Code = code;
 }