Exemplo n.º 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);
 }
Exemplo n.º 3
0
 public FileExistenceResult(ResultCode code, ResultBase other, string?message = null)
     : base(other, message)
 {
     Code = code;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BoolResult" /> class.
 /// </summary>
 public BoolResult(ResultBase other, string?message = null)
     : base(other, message)
 {
 }
Exemplo n.º 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;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Special method to ignore potentially not successful result of an operation explicitly.
 /// </summary>
 public static void IgnoreFailure(this ResultBase result)
 {
 }
Exemplo n.º 7
0
 /// <inheritdoc />
 protected override bool SuccessEquals(ResultBase other)
 {
     return(Code == ((PlaceFileResult)other).Code);
 }
Exemplo n.º 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;
 }
Exemplo n.º 9
0
 public GetStatsResult(ResultBase other, string?message = null)
     : base(other, message)
 {
 }
Exemplo n.º 10
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="PutResult" /> class.
 /// </summary>
 public PutResult(ResultBase other, string message = null)
     : base(other, message)
 {
 }
Exemplo n.º 11
0
 /// <inheritdoc />
 public Result(ResultBase other, string?message = null)
     : base(other, message)
 {
     _result = default;
 }
Exemplo n.º 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)
 {
 }
Exemplo n.º 13
0
 /// <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>();
 }
Exemplo n.º 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;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Returns true if the error is critical.
 /// </summary>
 public bool IsCritical(bool isCanceled) => isCanceled?ResultBase.IsCriticalForCancellation(Exception) : ResultBase.IsCritical(Exception);
Exemplo n.º 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;
 }
Exemplo n.º 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)
 {
 }
Exemplo n.º 18
0
 public PutResult(ResultBase other, ContentHash contentHash, string?message = null)
     : base(other, message)
 {
     ContentHash = contentHash;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 21
0
 /// <summary>
 /// Check if equal to another.
 /// </summary>
 protected bool EqualsBase(ResultBase other)
 {
     return(!(other is null) && ErrorMessage == other.ErrorMessage);
 }
Exemplo n.º 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;
 }
Exemplo n.º 23
0
 /// <nodoc />
 public DeleteResult(ResultBase other, string message)
     : base(other, message)
 {
     Code = ResultCode.Error;
 }
Exemplo n.º 24
0
        /// <inheritdoc />
        protected override bool SuccessEquals(ResultBase other)
        {
            var rhs = (OpenStreamResult)other;

            return(Code == rhs.Code && Stream == rhs.Stream);
        }
Exemplo n.º 25
0
 /// <nodoc />
 public static Result <T> FromError <T>(ResultBase other)
 {
     Contract.Requires(!other.Succeeded);
     return(new Result <T>(other));
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 28
0
 public PlaceFileResult(ResultBase other, ResultCode code, string?message = null)
     : base(other, message)
 {
     Code = code;
 }
Exemplo n.º 29
0
 public FileExistenceResult(ResultBase other, string?message = null)
     : base(other, message)
 {
     Code = ResultCode.Error;
 }
Exemplo n.º 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;
 }