Table of Contents

Struct Result<TValue>

Namespace
LightResults
Assembly
LightResults.dll

Represents a result.

public readonly struct Result<TValue> : IEquatable<Result<TValue>>, IActionableResult<TValue, Result<TValue>>, IResult<TValue>, IResult

Type Parameters

TValue

The type of the value of the result.

Implements

Inherited Members

Properties

Errors

Gets a read-only collection of errors associated with the result.

public IReadOnlyCollection<IError> Errors { get; }

Property Value

IReadOnlyCollection<IError>

Methods

AsFailure()

Converts the current LightResults.Result`1 to a failure LightResults.Result.

public Result AsFailure()

Returns

Result

A new instance of LightResults.Result containing the same error as the LightResults.Result`1, if any.

AsFailure<TDestination>()

Converts the current LightResults.Result`1 to a failure LightResults.Result`1.

public Result<TDestination> AsFailure<TDestination>()

Returns

Result<TDestination>

A new instance of LightResults.Result`1 containing the same error as the LightResults.Result`1, if any.

Type Parameters

TDestination

The type of the value of the failure result.

Equals(Result<TValue>)

Determines whether two LightResults.Result`1 instances are equal.

public bool Equals(Result<TValue> other)

Parameters

other Result<TValue>

The LightResults.Result`1 instance to compare with this instance.

Returns

bool

true if the specified LightResults.Result`1 is equal to this instance; otherwise, false.

Equals(object?)

Determines whether the specified object is equal to this instance.

public override bool Equals(object? obj)

Parameters

obj object?

The object to compare with this instance.

Returns

bool

true if the specified object is equal to this instance; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer hash code.

HasError<TError>()

Checks if the result contains an error of the specified type.

public bool HasError<TError>() where TError : IError

Returns

bool

true if an error of the specified type exists; otherwise, false.

Type Parameters

TError

The type of error to check for.

HasError<TError>(out TError)

Checks if the result contains an error of the specified type.

public bool HasError<TError>(out TError error) where TError : IError

Parameters

error TError

The error of the specified type.

Returns

bool

true if an error of the specified type exists; otherwise, false.

Type Parameters

TError

The type of error to check for.

IsFailure()

Determines whether the result failure.

public bool IsFailure()

Returns

bool

true if the result failure; otherwise, false.

IsFailure(out IError)

Determines whether the result failure.

public bool IsFailure(out IError error)

Parameters

error IError

The error of the result.

Returns

bool

true if the result failure; otherwise, false.

IsFailure(out IError, out TValue)

Determines whether the result failure.

public bool IsFailure(out IError error, out TValue value)

Parameters

error IError

The error of the result.

value TValue

The value of the result.

Returns

bool

true if the result failure; otherwise, false.

IsSuccess()

Determines whether the result was successful.

public bool IsSuccess()

Returns

bool

true if the result was successful; otherwise, false.

IsSuccess(out TValue)

Determines whether the result was successful.

public bool IsSuccess(out TValue value)

Parameters

value TValue

The value of the result.

Returns

bool

true if the result was successful; otherwise, false.

IsSuccess(out TValue, out IError)

Determines whether the result failure.

public bool IsSuccess(out TValue value, out IError error)

Parameters

value TValue

The value of the result.

error IError

The error of the result.

Returns

bool

true if the result was successful; otherwise, false.

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

Operators

operator ==(Result<TValue>, Result<TValue>)

Determines whether two LightResults.Result`1 instances are equal.

public static bool operator ==(Result<TValue> left, Result<TValue> right)

Parameters

left Result<TValue>

The first LightResults.Result`1 instance to compare.

right Result<TValue>

The second LightResults.Result`1 instance to compare.

Returns

bool

true if the specified LightResults.Result`1 instances are equal; otherwise, false.

implicit operator Result<TValue>(TValue)

Implicitly converts a value to a success LightResults.Result`1.

public static implicit operator Result<TValue>(TValue value)

Parameters

value TValue

The value to convert into a success result.

Returns

Result<TValue>

A new instance of LightResults.Result`1 representing a success result with the specified value.

implicit operator Result<TValue>(Error)

Implicitly converts an LightResults.Error to a failure LightResults.Result`1.

public static implicit operator Result<TValue>(Error error)

Parameters

error Error

The error to convert into a failure result.

Returns

Result<TValue>

A new instance of LightResults.Result`1 representing a failure result with the specified error.

operator !=(Result<TValue>, Result<TValue>)

Determines whether two LightResults.Result`1 instances are not equal.

public static bool operator !=(Result<TValue> left, Result<TValue> right)

Parameters

left Result<TValue>

The first LightResults.Result`1 instance to compare.

right Result<TValue>

The second LightResults.Result`1 instance to compare.

Returns

bool

true if the specified LightResults.Result`1 instances are not equal; otherwise, false.