Represents extension methods for type Result<T>.
Namespace: DotNext Assembly: DotNext.dll Syntaxpublic static class Result
Methods | Edit this page View Source Coalesce<T>(in Result<T>, in Result<T>)
Returns the second result if the first is unsuccessful.
Declarationpublic static ref readonly Result<T> Coalesce<T>(this in Result<T> first, in Result<T> second)
Parameters Type Name Description Result<T> first
The first result.
Result<T> secondThe second result.
Returns Type Description Result<T>The second result if the first is unsuccessful; otherwise, the first result.
Type Parameters Name Description TThe type of value.
| Edit this page View Source EnsureNotNull<T>(Result<T?>)Ensures that the specified result doesn't contain null value.
Declarationpublic static Result<T> EnsureNotNull<T>(this Result<T?> result) where T : class
Parameters Type Name Description Result<T> result
The result to be checked.
Returns Type Parameters Name Description TThe type of the result.
| Edit this page View Source EnsureNotNull<T, TException>(Result<T?>)Ensures that the specified result doesn't contain null value.
Declarationpublic static Result<T> EnsureNotNull<T, TException>(this Result<T?> result) where T : class where TException : Exception, new()
Parameters Type Name Description Result<T> result
The result to be checked.
Returns Type Description Result<T>The result containing non-null value; or as an error.
Type Parameters Name Description TThe type of the result.
TExceptionThe type of the exception to be returned from the null result.
| Edit this page View Source FromException<T>(Exception)Creates a new instance of Result<T> from the specified exception.
Declarationpublic static Result<T> FromException<T>(Exception e)
Parameters Type Name Description Exception e
The exception to be placed to the container.
Returns Type Parameters Name Description TThe type of the value.
| Edit this page View Source FromValue<T>(T)Creates a new instance of Result<T> from the specified value.
Declarationpublic static Result<T> FromValue<T>(T value)
Parameters Type Name Description T value
The value to be placed to the container.
Returns Type Parameters Name Description TThe type of the value.
| Edit this page View Source GetUnderlyingType(Type)Returns the underlying type argument of the specified result type.
Declarationpublic static Type? GetUnderlyingType(Type resultType)
Parameters Type Name Description Type resultType
Result type.
Returns Type Description TypeUnderlying type argument of the result type; otherwise, null.
| Edit this page View Source IsResult(Type)Indicates that the specified type is the result type.
Declarationpublic static bool IsResult(this Type resultType)
Parameters Returns Type Description bool
true, if specified type is result type; otherwise, false.
| Edit this page View Source OrNull<T>(in Result<T>)If a result is successful, returns it, otherwise null.
Declarationpublic static T? OrNull<T>(this in Result<T> result) where T : struct
Parameters Type Name Description Result<T> result
The result.
Returns Type Description T?Nullable value.
Type Parameters Name Description TValue type.
| Edit this page View Source OrNull<T, TError>(in Result<T, TError>)If a result is successful, returns it, otherwise null.
Declarationpublic static T? OrNull<T, TError>(this in Result<T, TError> result) where T : struct where TError : struct, Enum
Parameters Type Name Description Result<T, TError> result
The result.
Returns Type Description T?Nullable value.
Type Parameters Name Description TValue type.
TErrorThe type of the error code.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4