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); }
public FileExistenceResult(ResultCode code, ResultBase other, string?message = null) : base(other, message) { Code = code; }
/// <summary> /// Initializes a new instance of the <see cref="BoolResult" /> class. /// </summary> public BoolResult(ResultBase other, string?message = null) : base(other, message) { }
/// <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; }
/// <summary> /// Special method to ignore potentially not successful result of an operation explicitly. /// </summary> public static void IgnoreFailure(this ResultBase result) { }
/// <inheritdoc /> protected override bool SuccessEquals(ResultBase other) { return(Code == ((PlaceFileResult)other).Code); }
/// <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; }
public GetStatsResult(ResultBase other, string?message = null) : base(other, message) { }
/// <summary> /// Initializes a new instance of the <see cref="PutResult" /> class. /// </summary> public PutResult(ResultBase other, string message = null) : base(other, message) { }
/// <inheritdoc /> public Result(ResultBase other, string?message = null) : base(other, message) { _result = default; }
/// <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>(); }
/// <summary> /// Initializes a new instance of the <see cref="ErrorResult" /> class. /// </summary> public ErrorResult(ResultBase other, string?message = null) : base(other, message) { Message = message; }
/// <summary> /// Returns true if the error is critical. /// </summary> public bool IsCritical(bool isCanceled) => isCanceled?ResultBase.IsCriticalForCancellation(Exception) : ResultBase.IsCritical(Exception);
/// <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; }
/// <summary> /// Initializes a new instance of the <see cref="CopyFileResult"/> class. /// </summary> public CopyFileResult(ResultBase other, string message = null) : this(ResultCode.Unknown, other, message) { }
public PutResult(ResultBase other, ContentHash contentHash, string?message = null) : base(other, message) { ContentHash = contentHash; }
/// <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; }
/// <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; }
/// <summary> /// Check if equal to another. /// </summary> protected bool EqualsBase(ResultBase other) { return(!(other is null) && ErrorMessage == other.ErrorMessage); }
/// <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; }
/// <nodoc /> public DeleteResult(ResultBase other, string message) : base(other, message) { Code = ResultCode.Error; }
/// <inheritdoc /> protected override bool SuccessEquals(ResultBase other) { var rhs = (OpenStreamResult)other; return(Code == rhs.Code && Stream == rhs.Stream); }
/// <nodoc /> public static Result <T> FromError <T>(ResultBase other) { Contract.Requires(!other.Succeeded); return(new Result <T>(other)); }
/// <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; }
/// <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; }
public PlaceFileResult(ResultBase other, ResultCode code, string?message = null) : base(other, message) { Code = code; }
public FileExistenceResult(ResultBase other, string?message = null) : base(other, message) { Code = ResultCode.Error; }
/// <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; }