Table of Contents

Struct ComparisonInfo<T>

Namespace
Garyon.Extensions.Comparison
Assembly
Garyon.dll

Matches the result of a comparison along with its ComparisonSource<T>. The result is an integer indicating the relative order of the compared values, following the value semantics of the result of CompareTo(T).

public readonly record struct ComparisonInfo<T> : IEquatable<ComparisonInfo<T>>

Type Parameters

T
Implements
Inherited Members
Extension Methods

Constructors

ComparisonInfo(ComparisonSource<T>, int)

Matches the result of a comparison along with its ComparisonSource<T>. The result is an integer indicating the relative order of the compared values, following the value semantics of the result of CompareTo(T).

public ComparisonInfo(ComparisonSource<T> Source, int Result)

Parameters

Source ComparisonSource<T>

The comparison source.

Result int

The result of the comparison.

Properties

AreDifferent

Determines whether the compared values from the source are different.

public bool AreDifferent { get; }

Property Value

bool

AreEqual

Determines whether the compared values from the source are equal.

public bool AreEqual { get; }

Property Value

bool

Result

The result of the comparison.

public int Result { get; init; }

Property Value

int

Source

The comparison source.

public ComparisonSource<T> Source { get; init; }

Property Value

ComparisonSource<T>

Methods

ThenByAsync<TResult>(Func<T, Task<TResult>>)

Additionally compares the same values by another predicate asynchronously, without breaking fluent chaining.

public AsyncComparisonInfo<T> ThenByAsync<TResult>(Func<T, Task<TResult>> selector) where TResult : IComparable<TResult>

Parameters

selector Func<T, Task<TResult>>

Returns

AsyncComparisonInfo<T>

Type Parameters

TResult

ThenByAsync<TResult>(Func<T, ValueTask<TResult>>)

Additionally compares the same values by another predicate asynchronously, without breaking fluent chaining.

public AsyncComparisonInfo<T> ThenByAsync<TResult>(Func<T, ValueTask<TResult>> selector) where TResult : IComparable<TResult>

Parameters

selector Func<T, ValueTask<TResult>>

Returns

AsyncComparisonInfo<T>

Type Parameters

TResult

ThenByDescAsync<TResult>(Func<T, Task<TResult>>)

Additionally compares the same values by another predicate asynchronously in descending order, without breaking fluent chaining.

public AsyncComparisonInfo<T> ThenByDescAsync<TResult>(Func<T, Task<TResult>> selector) where TResult : IComparable<TResult>

Parameters

selector Func<T, Task<TResult>>

Returns

AsyncComparisonInfo<T>

Type Parameters

TResult

ThenByDescAsync<TResult>(Func<T, ValueTask<TResult>>)

Additionally compares the same values by another predicate asynchronously in descending order, without breaking fluent chaining.

public AsyncComparisonInfo<T> ThenByDescAsync<TResult>(Func<T, ValueTask<TResult>> selector) where TResult : IComparable<TResult>

Parameters

selector Func<T, ValueTask<TResult>>

Returns

AsyncComparisonInfo<T>

Type Parameters

TResult

ThenByDesc<TResult>(Func<T, Task<TResult>>)

Additionally compares the same values by another predicate asynchronously in descending order.

public ValueTask<ComparisonInfo<T>> ThenByDesc<TResult>(Func<T, Task<TResult>> selector) where TResult : IComparable<TResult>

Parameters

selector Func<T, Task<TResult>>

Returns

ValueTask<ComparisonInfo<T>>

Type Parameters

TResult

ThenByDesc<TResult>(Func<T, ValueTask<TResult>>)

Additionally compares the same values by another predicate asynchronously in descending order.

public ValueTask<ComparisonInfo<T>> ThenByDesc<TResult>(Func<T, ValueTask<TResult>> selector) where TResult : IComparable<TResult>

Parameters

selector Func<T, ValueTask<TResult>>

Returns

ValueTask<ComparisonInfo<T>>

Type Parameters

TResult

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

Additionally compares the same values by another predicate in descending order.

public ComparisonInfo<T> ThenByDesc<TResult>(Func<T, TResult> selector) where TResult : IComparable<TResult>

Parameters

selector Func<T, TResult>

The value selector to apply to the compared instances.

Returns

ComparisonInfo<T>

A comparison info representing the result of the additional comparison. The returned value will be the same as this current instance if AreDifferent returns true, otherwise it will be the result of ByDesc<TResult>(Func<T, TResult>) called on the same source.

Type Parameters

TResult

The type of the selected value.

ThenBy<TResult>(Func<T, Task<TResult>>)

Additionally compares the same values by another predicate asynchronously.

public ValueTask<ComparisonInfo<T>> ThenBy<TResult>(Func<T, Task<TResult>> selector) where TResult : IComparable<TResult>

Parameters

selector Func<T, Task<TResult>>

Returns

ValueTask<ComparisonInfo<T>>

Type Parameters

TResult

ThenBy<TResult>(Func<T, ValueTask<TResult>>)

Additionally compares the same values by another predicate asynchronously.

public ValueTask<ComparisonInfo<T>> ThenBy<TResult>(Func<T, ValueTask<TResult>> selector) where TResult : IComparable<TResult>

Parameters

selector Func<T, ValueTask<TResult>>

Returns

ValueTask<ComparisonInfo<T>>

Type Parameters

TResult

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

Additionally compares the same values by another predicate.

public ComparisonInfo<T> ThenBy<TResult>(Func<T, TResult> selector) where TResult : IComparable<TResult>

Parameters

selector Func<T, TResult>

The value selector to apply to the compared instances.

Returns

ComparisonInfo<T>

A comparison info representing the result of the additional comparison. The returned value will be the same as this current instance if AreDifferent returns true, otherwise it will be the result of By<TResult>(Func<T, TResult>) called on the same source.

Type Parameters

TResult

The type of the selected value.