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

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