Table of Contents

Class OperationResult

Namespace
AsiBackbone.Core.Results
Assembly
AsiBackbone.Core.dll

Represents the framework-neutral outcome of an operation.

public class OperationResult
Inheritance
OperationResult
Derived
Inherited Members

Constructors

OperationResult(bool, IReadOnlyList<OperationReason>, IReadOnlyList<string>)

Initializes a new instance of the OperationResult class.

protected OperationResult(bool succeeded, IReadOnlyList<OperationReason> reasons, IReadOnlyList<string> warnings)

Parameters

succeeded bool

A value indicating whether the operation succeeded.

reasons IReadOnlyList<OperationReason>

The reasons associated with the operation result.

warnings IReadOnlyList<string>

The warnings associated with the operation result.

Properties

Failed

Gets a value indicating whether the operation failed.

public bool Failed { get; }

Property Value

bool

HasWarnings

Gets a value indicating whether the operation result has warning messages.

public bool HasWarnings { get; }

Property Value

bool

ReasonCodes

Gets machine-readable reason codes associated with the operation result.

public IReadOnlyList<string> ReasonCodes { get; }

Property Value

IReadOnlyList<string>

Reasons

Gets the reasons associated with the operation result.

public IReadOnlyList<OperationReason> Reasons { get; }

Property Value

IReadOnlyList<OperationReason>

Succeeded

Gets a value indicating whether the operation succeeded.

public bool Succeeded { get; }

Property Value

bool

Warnings

Gets human-readable warning messages associated with the operation result.

public IReadOnlyList<string> Warnings { get; }

Property Value

IReadOnlyList<string>

Methods

Failure()

Creates a failed operation result using the default failure reason.

public static OperationResult Failure()

Returns

OperationResult

A failed operation result.

Failure(OperationReason)

Creates a failed operation result.

public static OperationResult Failure(OperationReason reason)

Parameters

reason OperationReason

The reason associated with the failed result.

Returns

OperationResult

A failed operation result.

Failure(IEnumerable<OperationReason>)

Creates a failed operation result.

public static OperationResult Failure(IEnumerable<OperationReason> reasons)

Parameters

reasons IEnumerable<OperationReason>

The reasons associated with the failed result.

Returns

OperationResult

A failed operation result.

Failure(IEnumerable<OperationReason>, IEnumerable<string>)

Creates a failed operation result with warnings.

public static OperationResult Failure(IEnumerable<OperationReason> reasons, IEnumerable<string> warnings)

Parameters

reasons IEnumerable<OperationReason>

The reasons associated with the failed result.

warnings IEnumerable<string>

The warnings associated with the failed result.

Returns

OperationResult

A failed operation result.

Failure(string, string)

Creates a failed operation result.

public static OperationResult Failure(string code, string message)

Parameters

code string

The machine-readable reason code.

message string

The human-readable reason message.

Returns

OperationResult

A failed operation result.

Failure<TValue>()

Creates a failed operation result using the default failure reason.

public static OperationResult<TValue> Failure<TValue>()

Returns

OperationResult<TValue>

A failed operation result.

Type Parameters

TValue

The result value type.

Failure<TValue>(OperationReason)

Creates a failed operation result.

public static OperationResult<TValue> Failure<TValue>(OperationReason reason)

Parameters

reason OperationReason

The reason associated with the failed result.

Returns

OperationResult<TValue>

A failed operation result.

Type Parameters

TValue

The result value type.

Failure<TValue>(IEnumerable<OperationReason>)

Creates a failed operation result.

public static OperationResult<TValue> Failure<TValue>(IEnumerable<OperationReason> reasons)

Parameters

reasons IEnumerable<OperationReason>

The reasons associated with the failed result.

Returns

OperationResult<TValue>

A failed operation result.

Type Parameters

TValue

The result value type.

Failure<TValue>(IEnumerable<OperationReason>, IEnumerable<string>)

Creates a failed operation result with warnings.

public static OperationResult<TValue> Failure<TValue>(IEnumerable<OperationReason> reasons, IEnumerable<string> warnings)

Parameters

reasons IEnumerable<OperationReason>

The reasons associated with the failed result.

warnings IEnumerable<string>

The warnings associated with the failed result.

Returns

OperationResult<TValue>

A failed operation result.

Type Parameters

TValue

The result value type.

Failure<TValue>(string, string)

Creates a failed operation result.

public static OperationResult<TValue> Failure<TValue>(string code, string message)

Parameters

code string

The machine-readable reason code.

message string

The human-readable reason message.

Returns

OperationResult<TValue>

A failed operation result.

Type Parameters

TValue

The result value type.

NormalizeReasons(IEnumerable<OperationReason>?)

Normalizes operation reasons and provides a default failure reason when none are supplied.

protected static IReadOnlyList<OperationReason> NormalizeReasons(IEnumerable<OperationReason>? reasons)

Parameters

reasons IEnumerable<OperationReason>

The reasons to normalize.

Returns

IReadOnlyList<OperationReason>

A normalized reason collection.

NormalizeWarnings(IEnumerable<string>?)

Normalizes warning messages.

protected static IReadOnlyList<string> NormalizeWarnings(IEnumerable<string>? warnings)

Parameters

warnings IEnumerable<string>

The warnings to normalize.

Returns

IReadOnlyList<string>

A normalized warning collection.

Success()

Creates a successful operation result.

public static OperationResult Success()

Returns

OperationResult

A successful operation result.

Success(IEnumerable<string>)

Creates a successful operation result with warnings.

public static OperationResult Success(IEnumerable<string> warnings)

Parameters

warnings IEnumerable<string>

The warnings associated with the successful result.

Returns

OperationResult

A successful operation result.

Success<TValue>(TValue)

Creates a successful operation result with a value.

public static OperationResult<TValue> Success<TValue>(TValue value)

Parameters

value TValue

The operation value.

Returns

OperationResult<TValue>

A successful operation result.

Type Parameters

TValue

The result value type.

Success<TValue>(TValue, IEnumerable<string>)

Creates a successful operation result with a value and warnings.

public static OperationResult<TValue> Success<TValue>(TValue value, IEnumerable<string> warnings)

Parameters

value TValue

The operation value.

warnings IEnumerable<string>

The warnings associated with the successful result.

Returns

OperationResult<TValue>

A successful operation result.

Type Parameters

TValue

The result value type.

ToFailure()

Creates a failed operation result from this result's reasons and warnings.

public OperationResult ToFailure()

Returns

OperationResult

A failed operation result.