Show / Hide Table of Contents

Interface IOptionMonad<T>

Represents common interface for all option monads.

Inherited Members
ISupplier<object>.Invoke()
ISupplier<object>.NullOrDefault
IFunctional<Func<object>>.ToDelegate()
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public interface IOptionMonad<T> : ISupplier<object?>, IFunctional<Func<object?>>
Type Parameters
Name Description
T

The type of the value in the container.

Properties

| Edit this page View Source

HasValue

Indicates that this monad contains a value.

Declaration
bool HasValue { get; }
Property Value
Type Description
bool
| Edit this page View Source

ValueOrDefault

If a value is present, returns the value, otherwise return default value.

Declaration
T? ValueOrDefault { get; }
Property Value
Type Description
T

The value, if present, otherwise default.

Methods

| Edit this page View Source

Or(T?)

Returns the value if present; otherwise return default value.

Declaration
T? Or(T? defaultValue)
Parameters
Type Name Description
T defaultValue

The value to be returned if there is no value present.

Returns
Type Description
T

The value, if present, otherwise defaultValue.

| Edit this page View Source

OrInvoke(Func<T>)

Returns the value if present; otherwise invoke delegate.

Declaration
T OrInvoke(Func<T> defaultFunc)
Parameters
Type Name Description
Func<T> defaultFunc

A delegate to be invoked if value is not present.

Returns
Type Description
T

The value, if present, otherwise returned from delegate.

| Edit this page View Source

TryGet(out T?)

Attempts to extract value from container if it is present.

Declaration
bool TryGet(out T? value)
Parameters
Type Name Description
T value

Extracted value.

Returns
Type Description
bool

true if value is present; otherwise, false.

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.GetUserData<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
ExpressionBuilder.Const<T>(T)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan, CancellationToken)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾