Class OneOfBase<T1, T2>

Namespace
REslava.Result.AdvancedPatterns
Assembly
REslava.Result.dll

Shared dispatch base for discriminated unions of two types. Inherited by OneOf<T1, T2> and ErrorsOf<T1, T2>.

public abstract class OneOfBase<T1, T2>

Type Parameters

T1
T2
Inheritance
OneOfBase<T1, T2>
Derived
ErrorsOf<T1, T2>
OneOf<T1, T2>
Inherited Members
Extension Methods

Properties

AsT1

public T1 AsT1 { get; }

Property Value

T1

AsT2

public T2 AsT2 { get; }

Property Value

T2

IsT1

public bool IsT1 { get; }

Property Value

bool

IsT2

public bool IsT2 { get; }

Property Value

bool

Methods

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

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

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

Match<TResult>(Func<T1, TResult>, Func<T2, TResult>)

public TResult Match<TResult>(Func<T1, TResult> case1, Func<T2, TResult> case2)

Parameters

case1 Func<T1, TResult>
case2 Func<T2, TResult>

Returns

TResult

Type Parameters

TResult

Switch(Action<T1>, Action<T2>)

public void Switch(Action<T1> case1, Action<T2> case2)

Parameters

case1 Action<T1>
case2 Action<T2>

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.