Method If
View SourceIf<TResult>(Func<bool>, IAsyncEnumerable<TResult>)
Returns an enumerable sequence if the evaluation result of the given condition is true, otherwise returns an empty sequence.
Declaration
public static IAsyncEnumerable<TResult> If<TResult>(Func<bool> condition, IAsyncEnumerable<TResult> thenSource)
Parameters
Type | Name | Description |
---|---|---|
Func<bool> | condition | Condition to evaluate. |
IAsyncEnumerable<TResult> | thenSource | Sequence to return in case the condition evaluates true. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TResult> | The given input sequence if the condition evaluates true; otherwise, an empty sequence. |
Type Parameters
Name | Description |
---|---|
TResult | Result sequence element type. |
Remarks
condition
is not evaluated until enumeration. If the value is true, then
thenSource
is enumerated. Otherwise, the sequence will be empty.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
If<TResult>(Func<ValueTask<bool>>, IAsyncEnumerable<TResult>)
Returns an enumerable sequence if the evaluation result of the given condition is true, otherwise returns an empty sequence.
Declaration
public static IAsyncEnumerable<TResult> If<TResult>(Func<ValueTask<bool>> condition, IAsyncEnumerable<TResult> thenSource)
Parameters
Type | Name | Description |
---|---|---|
Func<ValueTask<bool>> | condition | Condition to evaluate. |
IAsyncEnumerable<TResult> | thenSource | Sequence to return in case the condition evaluates true. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TResult> | The given input sequence if the condition evaluates true; otherwise, an empty sequence. |
Type Parameters
Name | Description |
---|---|
TResult | Result sequence element type. |
Remarks
condition
is not evaluated until enumeration. If the value is true, then
thenSource
is enumerated. Otherwise, the sequence will be empty.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
If<TResult>(Func<bool>, IAsyncEnumerable<TResult>, IAsyncEnumerable<TResult>)
Returns an enumerable sequence based on the evaluation result of the given condition.
Declaration
public static IAsyncEnumerable<TResult> If<TResult>(Func<bool> condition, IAsyncEnumerable<TResult> thenSource, IAsyncEnumerable<TResult> elseSource)
Parameters
Type | Name | Description |
---|---|---|
Func<bool> | condition | Condition to evaluate. |
IAsyncEnumerable<TResult> | thenSource | Sequence to return in case the condition evaluates true. |
IAsyncEnumerable<TResult> | elseSource | Sequence to return in case the condition evaluates false. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TResult> | Either of the two input sequences based on the result of evaluating the condition. |
Type Parameters
Name | Description |
---|---|
TResult | Result sequence element type. |
Remarks
condition
is not evaluated until enumeration. If the value is true, then
thenSource
is enumerated. Otherwise, elseSource
will be enumerated.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
If<TResult>(Func<ValueTask<bool>>, IAsyncEnumerable<TResult>, IAsyncEnumerable<TResult>)
Returns an enumerable sequence based on the evaluation result of the given condition.
Declaration
public static IAsyncEnumerable<TResult> If<TResult>(Func<ValueTask<bool>> condition, IAsyncEnumerable<TResult> thenSource, IAsyncEnumerable<TResult> elseSource)
Parameters
Type | Name | Description |
---|---|---|
Func<ValueTask<bool>> | condition | Condition to evaluate. |
IAsyncEnumerable<TResult> | thenSource | Sequence to return in case the condition evaluates true. |
IAsyncEnumerable<TResult> | elseSource | Sequence to return in case the condition evaluates false. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TResult> | Either of the two input sequences based on the result of evaluating the condition. |
Type Parameters
Name | Description |
---|---|
TResult | Result sequence element type. |
Remarks
condition
is not evaluated until enumeration. If the value is true, then
thenSource
is enumerated. Otherwise, elseSource
will be enumerated.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|