Struct Result<T>
Implements
Inherited Members
Namespace: Color_Chan.Discord.Core.Results
Assembly: Color-Chan.Discord.Core.dll
Syntax
public readonly struct Result<T> : IResult
Type Parameters
Name | Description |
---|---|
T |
Properties
| Improve this Doc View SourceEntity
The result entity.
Declaration
public readonly T Entity { get; }
Property Value
Type | Description |
---|---|
T |
ErrorResult
The error of the IResult.
Declaration
public readonly IErrorResult ErrorResult { get; }
Property Value
Type | Description |
---|---|
IErrorResult |
Remarks
Null if the result doesn't have an inner result.
InnerResult
The inner IResult.
Declaration
public readonly IResult InnerResult { get; }
Property Value
Type | Description |
---|---|
IResult |
Remarks
| Improve this Doc View SourceIsSuccessful
Whether or not the IResult is successful.
Declaration
public readonly bool IsSuccessful { get; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
| Improve this Doc View SourceFromError(T, IErrorResult)
Initializes a new unsuccessful instance of Result.
Declaration
public static Result<T> FromError(T entity, IErrorResult errorResult)
Parameters
Type | Name | Description |
---|---|---|
T | entity | The |
IErrorResult | errorResult | The IErrorResult containing the error details. |
Returns
Type | Description |
---|---|
Result<T> | The unsuccessful instance of Result. |
FromError(T, IErrorResult, IResult)
Initializes a new unsuccessful instance of Result.
Declaration
public static Result<T> FromError(T entity, IErrorResult errorResult, IResult innerResult)
Parameters
Type | Name | Description |
---|---|---|
T | entity | The |
IErrorResult | errorResult | The IErrorResult containing the error details. |
IResult | innerResult | The inner IResult. |
Returns
Type | Description |
---|---|
Result<T> | The unsuccessful instance of Result. |
FromSuccess(T)
Initializes a new successful instance of Result.
Declaration
public static Result<T> FromSuccess(T entity)
Parameters
Type | Name | Description |
---|---|---|
T | entity | The |
Returns
Type | Description |
---|---|
Result<T> | The successful instance of Result. |
Operators
| Improve this Doc View SourceImplicit(ErrorResult to Result<T>)
Creates a Result<T> from an ErrorResult.
Declaration
public static implicit operator Result<T>(ErrorResult error)
Parameters
Type | Name | Description |
---|---|---|
ErrorResult | error | The ErrorResult. |
Returns
Type | Description |
---|---|
Result<T> | The unsuccessful instance of Result. |
Implicit(Exception to Result<T>)
Declaration
public static implicit operator Result<T>(Exception exception)
Parameters
Type | Name | Description |
---|---|---|
Exception | exception | The Exception. |
Returns
Type | Description |
---|---|
Result<T> | The unsuccessful instance of Result. |