DotNext by .NET Foundation and Contributors

<PackageReference Include="DotNext" Version="4.9.0" />

.NET API 564,632 bytes

 Result<T>

public struct Result<T> : IResultMonad<T, Exception, Result<T>>, IResultMonad<T, Exception>, IOptionMonad<T>, ISupplier<object>, IFunctional<Func<object>>, IOptionMonad<T, Result<T>>
Represents a result of operation which can be actual result or exception.
public Exception Error { get; }

Gets exception associated with this result.

public bool IsSuccessful { get; }

Indicates that the result is successful.

public T Value { get; }

Extracts the actual result.

public Result(T value)

Initializes a new successful result.

public Result(Exception error)

Initializes a new unsuccessful result.

public static Result<T> FromOptional(ref Optional optional)

Creates Result<T> from Optional<T> instance.

public static bool op_BitwiseAnd(ref Result left, ref Result right)

Indicates that both results are successful.

public static T op_Explicit(ref Result result)

Extracts actual result.

public static Result<T> op_Explicit(ref Optional optional)

Converts Optional<T> to Result<T>.

public static bool op_False(ref Result result)

Indicates that the result represents error.

public static Optional<T> op_Implicit(ref Result result)

Converts the result into Optional<T>.

public static Result<T> op_Implicit(T result)

Converts value into the result.

public static bool op_True(ref Result result)

Indicates that the result is successful.

public Result<object> Box()

Gets boxed representation of the result.

public Result<TResult> Convert<TResult>(Converter<T, TResult> converter)

If successful result is present, apply the provided mapping function hiding any exception caused by the converter.

public Result<TResult> Convert<TResult>(method converter)

public T Or(T defaultValue)

Returns the value if present; otherwise return default value.

public T OrDefault()

Returns the value if present; otherwise return default value.

public T OrInvoke(Func<T> defaultFunc)

Returns the value if present; otherwise invoke delegate.

public T OrInvoke(method defaultFunc)

public T OrInvoke(Func<Exception, T> defaultFunc)

Returns the value if present; otherwise invoke delegate.

public T OrInvoke(method defaultFunc)

public bool TryGet(out T value)

Attempts to extract value from container if it is present.

public Optional<T> TryGet()

Converts the result into Optional<T>.