Table of Contents

Struct Either<T1, T2, T3, T4, T5, T6>

Namespace
SodaFlow.Functional
Assembly
SodaFlow.Functional.dll

A value which is one of six possibilities.

[PublicAPI]
public struct Either<T1, T2, T3, T4, T5, T6> : IEitherOfSix, IEither, IEquatable<Either<T1, T2, T3, T4, T5, T6>>

Type Parameters

T1

The type of the first possibility.

T2

The type of the second possibility.

T3

The type of the third possibility.

T4

The type of the fourth possibility.

T5

The type of the fifth possibility.

T6

The type of the sixth possibility.

Implements
IEquatable<Either<T1, T2, T3, T4, T5, T6>>
Inherited Members
Extension Methods

Remarks

A discriminated union. The value is one of the six cases. Which one it is is part of the value, and not something the caller must monitor next to it. There is no property that hands the value out unchecked. Read it with Match, or with one of the helpers on it, thus the code must answer each case. This is a struct, so default is a correct instance. It holds the first case, with the default value of T1.

Methods

Equals(Either<T1, T2, T3, T4, T5, T6>)

Gives true when the given instance is equal to this one.

Equals(object?)

Gives true when the given object is an either of this same type which is equal to this one.

Fifth(T5)

Creates an either holding the given value as its fifth case.

First(T1)

Creates an either holding the given value as its first case.

Fourth(T4)

Creates an either holding the given value as its fourth case.

GetHashCode()

Gives a hash code that agrees with operator ==(Either<T1, T2, T3, T4, T5, T6>, Either<T1, T2, T3, T4, T5, T6>).

IsFifth()

Gives true when this holds the fifth case.

IsFirst()

Gives true when this holds the first case.

IsFourth()

Gives true when this holds the fourth case.

IsSecond()

Gives true when this holds the second case.

IsSixth()

Gives true when this holds the sixth case.

IsThird()

Gives true when this holds the third case.

MapFifth<T>(Func<T5, T>)

Transforms the value if this holds the fifth case, and passes each other case through unchanged.

MapFirst<T>(Func<T1, T>)

Transforms the value if this holds the first case, and passes each other case through unchanged.

MapFourth<T>(Func<T4, T>)

Transforms the value if this holds the fourth case, and passes each other case through unchanged.

MapSecond<T>(Func<T2, T>)

Transforms the value if this holds the second case, and passes each other case through unchanged.

MapSixth<T>(Func<T6, T>)

Transforms the value if this holds the sixth case, and passes each other case through unchanged.

MapThird<T>(Func<T3, T>)

Transforms the value if this holds the third case, and passes each other case through unchanged.

MatchAsyncVoid(Func<T1, Task>, Func<T2, Task>, Func<T3, Task>, Func<T4, Task>, Func<T5, Task>, Func<T6, Task>)

Runs one of the six asynchronous actions depending on which case is held.

MatchAsync<T>(Func<T1, Task<T>>, Func<T2, Task<T>>, Func<T3, Task<T>>, Func<T4, Task<T>>, Func<T5, Task<T>>, Func<T6, Task<T>>)

Runs one of the six asynchronous functions depending on which case is held, and returns its result.

MatchVoid(Action<T1>, Action<T2>, Action<T3>, Action<T4>, Action<T5>, Action<T6>)

Runs one of the six actions depending on which case is held.

Match<T>(Func<T1, T>, Func<T2, T>, Func<T3, T>, Func<T4, T>, Func<T5, T>, Func<T6, T>)

Runs one of the six functions depending on which case is held, and returns its result.

Second(T2)

Creates an either holding the given value as its second case.

Sixth(T6)

Creates an either holding the given value as its sixth case.

Third(T3)

Creates an either holding the given value as its third case.

ToString()

Returns a readable description of this instance, for diagnostics.

TryGetFifth()

Gets the held value if this holds the fifth case.

TryGetFirst()

Gets the held value if this holds the first case.

TryGetFourth()

Gets the held value if this holds the fourth case.

TryGetSecond()

Gets the held value if this holds the second case.

TryGetSixth()

Gets the held value if this holds the sixth case.

TryGetThird()

Gets the held value if this holds the third case.

Operators

operator ==(Either<T1, T2, T3, T4, T5, T6>, Either<T1, T2, T3, T4, T5, T6>)

Gives true when two instances hold the same case with equal values.

implicit operator Either<T1, T2, T3, T4, T5, T6>(EitherFifth<T5>)

Changes a value marked for the fifth position into an either of this type.

implicit operator Either<T1, T2, T3, T4, T5, T6>(EitherFirst<T1>)

Changes a value marked for the first position into an either of this type.

implicit operator Either<T1, T2, T3, T4, T5, T6>(EitherFourth<T4>)

Changes a value marked for the fourth position into an either of this type.

implicit operator Either<T1, T2, T3, T4, T5, T6>(EitherSecond<T2>)

Changes a value marked for the second position into an either of this type.

implicit operator Either<T1, T2, T3, T4, T5, T6>(EitherSixth<T6>)

Changes a value marked for the sixth position into an either of this type.

implicit operator Either<T1, T2, T3, T4, T5, T6>(EitherThird<T3>)

Changes a value marked for the third position into an either of this type.

operator !=(Either<T1, T2, T3, T4, T5, T6>, Either<T1, T2, T3, T4, T5, T6>)

Gives true when two instances are different. This negates operator ==(Either<T1, T2, T3, T4, T5, T6>, Either<T1, T2, T3, T4, T5, T6>).