Show / Hide Table of Contents

Struct Option<T>

Represents an option type that can contain a value or be empty (None).

Implements
IEquatable<Option<T>>
IComparable<Option<T>>
Inherited Members
System.ValueType.ToString()
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: MediatorForge.Results
Assembly: MediatorForge.dll
Syntax
public readonly struct Option<T>
Type Parameters
Name Description
T

The type of the value.

Properties

| Improve this Doc View Source

IsNone

Gets a value indicating whether this instance does not contain a value.

Declaration
public readonly bool IsNone { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsSome

Gets a value indicating whether this instance contains a value.

Declaration
public readonly bool IsSome { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

None

Gets an instance of Option<T> that represents no value.

Declaration
public static readonly Option<T> None { get; }
Property Value
Type Description
Option<T>

Methods

| Improve this Doc View Source

CompareTo(Option<T>)

Compares this instance with another Option<T> and returns an integer that indicates whether this instance precedes, follows, or occurs in the same position in the sort order as the other Option<T>.

Declaration
public readonly int CompareTo(Option<T> other)
Parameters
Type Name Description
Option<T> other

An Option<T> to compare with this instance.

Returns
Type Description
System.Int32

A value that indicates the relative order of the objects being compared.

| Improve this Doc View Source

Equals(Option<T>)

Determines whether this instance and another specified Option<T> have the same value.

Declaration
public readonly bool Equals(Option<T> other)
Parameters
Type Name Description
Option<T> other

The Option<T> to compare to this instance.

Returns
Type Description
System.Boolean

true if the value of the specified Option<T> is equal to the value of this instance; otherwise, false.

| Improve this Doc View Source

Equals(Object)

Determines whether the specified object is equal to this instance.

Declaration
public override readonly bool Equals(object obj)
Parameters
Type Name Description
System.Object obj

The object to compare with this instance.

Returns
Type Description
System.Boolean

true if the specified object is equal to this instance; otherwise, false.

Overrides
System.ValueType.Equals(System.Object)
| Improve this Doc View Source

GetHashCode()

Returns the hash code for this instance.

Declaration
public override readonly int GetHashCode()
Returns
Type Description
System.Int32

A hash code for the current object.

Overrides
System.ValueType.GetHashCode()
| Improve this Doc View Source

Match(Action<T>, Action)

Executes one of the specified functions based on whether this instance contains a value.

Declaration
public readonly void Match(Action<T> onSome, Action onNone)
Parameters
Type Name Description
Action<T> onSome

The function to execute if this instance contains a value.

Action onNone

The function to execute if this instance does not contain a value.

| Improve this Doc View Source

Match<TResult>(Func<T, TResult>, Func<TResult>)

Executes one of the specified functions based on whether this instance contains a value.

Declaration
public readonly TResult Match<TResult>(Func<T, TResult> onSome, Func<TResult> onNone)
Parameters
Type Name Description
Func<T, TResult> onSome

The function to execute if this instance contains a value.

Func<TResult> onNone

The function to execute if this instance does not contain a value.

Returns
Type Description
TResult

The result of the executed function.

Type Parameters
Name Description
TResult

The type of the result produced by the functions.

| Improve this Doc View Source

OnNone(Action)

Executes the specified action if this instance does not contain a value.

Declaration
public readonly void OnNone(Action onNone)
Parameters
Type Name Description
Action onNone

The action to execute if this instance does not contain a value.

| Improve this Doc View Source

OnSome(Action<T>)

Executes the specified action if this instance contains a value.

Declaration
public readonly void OnSome(Action<T> onSome)
Parameters
Type Name Description
Action<T> onSome

The action to execute if this instance contains a value.

| Improve this Doc View Source

Some(T)

Creates an instance of Option<T> that contains a value.

Declaration
public static Option<T> Some(T value)
Parameters
Type Name Description
T value

The value to be contained.

Returns
Type Description
Option<T>

An Option<T> containing the specified value.

Operators

| Improve this Doc View Source

Equality(Option<T>, Option<T>)

Determines whether two Option<T> instances are equal.

Declaration
public static bool operator ==(Option<T> left, Option<T> right)
Parameters
Type Name Description
Option<T> left

The first Option<T> to compare.

Option<T> right

The second Option<T> to compare.

Returns
Type Description
System.Boolean

true if the two Option<T> instances are equal; otherwise, false.

| Improve this Doc View Source

GreaterThan(Option<T>, Option<T>)

Determines whether one Option<T> instance follows another in the sort order.

Declaration
public static bool operator>(Option<T> left, Option<T> right)
Parameters
Type Name Description
Option<T> left

The first Option<T> to compare.

Option<T> right

The second Option<T> to compare.

Returns
Type Description
System.Boolean

true if the first Option<T> follows the second in the sort order; otherwise, false.

| Improve this Doc View Source

GreaterThanOrEqual(Option<T>, Option<T>)

Determines whether one Option<T> instance follows or is equal to another in the sort order.

Declaration
public static bool operator >=(Option<T> left, Option<T> right)
Parameters
Type Name Description
Option<T> left

The first Option<T> to compare.

Option<T> right

The second Option<T> to compare.

Returns
Type Description
System.Boolean

true if the first Option<T> follows or is equal to the second in the sort order; otherwise, false.

| Improve this Doc View Source

Implicit(T to Option<T>)

Implicitly converts a value to an Option<T> containing that value.

Declaration
public static implicit operator Option<T>(T value)
Parameters
Type Name Description
T value

The value to convert.

Returns
Type Description
Option<T>
| Improve this Doc View Source

Inequality(Option<T>, Option<T>)

Determines whether two Option<T> instances are not equal.

Declaration
public static bool operator !=(Option<T> left, Option<T> right)
Parameters
Type Name Description
Option<T> left

The first Option<T> to compare.

Option<T> right

The second Option<T> to compare.

Returns
Type Description
System.Boolean

true if the two Option<T> instances are not equal; otherwise, false.

| Improve this Doc View Source

LessThan(Option<T>, Option<T>)

Determines whether one Option<T> instance precedes another in the sort order.

Declaration
public static bool operator <(Option<T> left, Option<T> right)
Parameters
Type Name Description
Option<T> left

The first Option<T> to compare.

Option<T> right

The second Option<T> to compare.

Returns
Type Description
System.Boolean

true if the first Option<T> precedes the second in the sort order; otherwise, false.

| Improve this Doc View Source

LessThanOrEqual(Option<T>, Option<T>)

Determines whether one Option<T> instance precedes or is equal to another in the sort order.

Declaration
public static bool operator <=(Option<T> left, Option<T> right)
Parameters
Type Name Description
Option<T> left

The first Option<T> to compare.

Option<T> right

The second Option<T> to compare.

Returns
Type Description
System.Boolean

true if the first Option<T> precedes or is equal to the second in the sort order; otherwise, false.

Implements

IEquatable<>
IComparable<>
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX