Show / Hide Table of Contents

Class Result

Represents extension methods for type Result<T>.

Inheritance
object
Result
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public 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.

Declaration
public 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> second

The second result.

Returns
Type Description
Result<T>

The second result if the first is unsuccessful; otherwise, the first result.

Type Parameters
Name Description
T

The type of value.

| Edit this page View Source

FromException<T>(Exception)

Creates a new instance of Result<T> from the specified exception.

Declaration
public static Result<T> FromException<T>(Exception e)
Parameters
Type Name Description
Exception e

The exception to be placed to the container.

Returns
Type Description
Result<T>

The exception encapsulated by Result<T>.

Type Parameters
Name Description
T

The type of the value.

| Edit this page View Source

FromValue<T>(T)

Creates a new instance of Result<T> from the specified value.

Declaration
public static Result<T> FromValue<T>(T value)
Parameters
Type Name Description
T value

The value to be placed to the container.

Returns
Type Description
Result<T>

The value encapsulated by Result<T>.

Type Parameters
Name Description
T

The type of the value.

| Edit this page View Source

GetUnderlyingType(Type)

Returns the underlying type argument of the specified result type.

Declaration
public static Type? GetUnderlyingType(Type resultType)
Parameters
Type Name Description
Type resultType

Result type.

Returns
Type Description
Type

Underlying type argument of result type; otherwise, null.

| Edit this page View Source

IsResult(Type)

Indicates that specified type is result type.

Declaration
public static bool IsResult(this Type resultType)
Parameters
Type Name Description
Type resultType

The type of Result<T>.

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.

Declaration
public 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
T

Value type.

| Edit this page View Source

OrNull<T, TError>(in Result<T, TError>)

If a result is successful, returns it, otherwise null.

Declaration
public 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
T

Value type.

TError

The type of the error code.

  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾