Table of Contents

Class Result<T>

Namespace
Glitch9

Represents a result object that includes a data, providing success, failure, and error states.

public class Result<T> : Result, IResult

Type Parameters

T

The type of the data.

Inheritance
Result<T>
Implements
Derived
Inherited Members
Extension Methods

Properties

Value

Gets the value associated with the result.

public T Value { get; set; }

Property Value

T

Methods

Fail(T, Exception, params string[])

Creates an error result with a specified value, exception, and additional messages.

public static Result<T> Fail(T value, Exception ex, params string[] failReasons)

Parameters

value T

The value to associate with the result.

ex Exception

The exception causing the error.

failReasons string[]

Additional messages to associate with the error.

Returns

Result<T>

An error IResult with a value.

Fail(T, string)

Creates a failed result with a specified value and an optional failure reason.

public static Result<T> Fail(T value, string failReason = null)

Parameters

value T

The value to associate with the result.

failReason string

The reason for the failure.

Returns

Result<T>

A failed IResult with a value.

Success(T)

Creates a successful result with a specified value.

public static Result<T> Success(T value)

Parameters

value T

The value to associate with the result.

Returns

Result<T>

A successful IResult with a value.