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
TThe value to associate with the result.
ex
ExceptionThe exception causing the error.
failReasons
string[]Additional messages to associate with the error.
Returns
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
TThe value to associate with the result.
failReason
stringThe reason for the failure.
Returns
Success(T)
Creates a successful result with a specified value.
public static Result<T> Success(T value)
Parameters
value
TThe value to associate with the result.