Method Case
View SourceCase<TValue, TResult>(Func<TValue>, IDictionary<TValue, IAsyncEnumerable<TResult>>)
Returns a sequence from a dictionary based on the result of evaluating a selector function.
Declaration
public static IAsyncEnumerable<TResult> Case<TValue, TResult>(Func<TValue> selector, IDictionary<TValue, IAsyncEnumerable<TResult>> sources) where TValue : notnull
Parameters
Type | Name | Description |
---|---|---|
Func<TValue> | selector | Selector function used to pick a sequence from the given sources. |
IDictionary<TValue, IAsyncEnumerable<TResult>> | sources | Dictionary mapping selector values onto resulting sequences. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TResult> | The source sequence corresponding with the evaluated selector value; otherwise, an empty sequence. |
Type Parameters
Name | Description |
---|---|
TValue | Type of the selector value. |
TResult | Result sequence element type. |
Remarks
selector
is not evaluated until enumeration. The value returned will be used to select a
sequence from sources
; enumeration will continue with items from that sequence.
If the value returned by selector
is not present in sources
, the resulting
sequence will be empty.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Case<TValue, TResult>(Func<ValueTask<TValue>>, IDictionary<TValue, IAsyncEnumerable<TResult>>)
Returns a sequence from a dictionary based on the result of evaluating a selector function.
Declaration
public static IAsyncEnumerable<TResult> Case<TValue, TResult>(Func<ValueTask<TValue>> selector, IDictionary<TValue, IAsyncEnumerable<TResult>> sources) where TValue : notnull
Parameters
Type | Name | Description |
---|---|---|
Func<ValueTask<TValue>> | selector | Selector function used to pick a sequence from the given sources. |
IDictionary<TValue, IAsyncEnumerable<TResult>> | sources | Dictionary mapping selector values onto resulting sequences. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TResult> | The source sequence corresponding with the evaluated selector value; otherwise, an empty sequence. |
Type Parameters
Name | Description |
---|---|
TValue | Type of the selector value. |
TResult | Result sequence element type. |
Remarks
selector
is not evaluated until enumeration. The value returned will be used to select a
sequence from sources
; enumeration will continue with items from that sequence.
If the value returned by selector
is not present in sources
, the resulting
sequence will be empty.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Case<TValue, TResult>(Func<TValue>, IDictionary<TValue, IAsyncEnumerable<TResult>>, IAsyncEnumerable<TResult>)
Returns a sequence from a dictionary based on the result of evaluating a selector function.
Declaration
public static IAsyncEnumerable<TResult> Case<TValue, TResult>(Func<TValue> selector, IDictionary<TValue, IAsyncEnumerable<TResult>> sources, IAsyncEnumerable<TResult> defaultSource) where TValue : notnull
Parameters
Type | Name | Description |
---|---|---|
Func<TValue> | selector | Selector function used to pick a sequence from the given sources. |
IDictionary<TValue, IAsyncEnumerable<TResult>> | sources | Dictionary mapping selector values onto resulting sequences. |
IAsyncEnumerable<TResult> | defaultSource | Default sequence to return in case there's no corresponding source for the computed selector value. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TResult> | The source sequence corresponding with the evaluated selector value; otherwise, an empty sequence. |
Type Parameters
Name | Description |
---|---|
TValue | Type of the selector value. |
TResult | Result sequence element type. |
Remarks
selector
is not evaluated until enumeration. The value returned will be used to select a
sequence from sources
; enumeration will continue with items from that sequence.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Case<TValue, TResult>(Func<ValueTask<TValue>>, IDictionary<TValue, IAsyncEnumerable<TResult>>, IAsyncEnumerable<TResult>)
Returns a sequence from a dictionary based on the result of evaluating a selector function.
Declaration
public static IAsyncEnumerable<TResult> Case<TValue, TResult>(Func<ValueTask<TValue>> selector, IDictionary<TValue, IAsyncEnumerable<TResult>> sources, IAsyncEnumerable<TResult> defaultSource) where TValue : notnull
Parameters
Type | Name | Description |
---|---|---|
Func<ValueTask<TValue>> | selector | Selector function used to pick a sequence from the given sources. |
IDictionary<TValue, IAsyncEnumerable<TResult>> | sources | Dictionary mapping selector values onto resulting sequences. |
IAsyncEnumerable<TResult> | defaultSource | Default sequence to return in case there's no corresponding source for the computed selector value. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TResult> | The source sequence corresponding with the evaluated selector value; otherwise, an empty sequence. |
Type Parameters
Name | Description |
---|---|
TValue | Type of the selector value. |
TResult | Result sequence element type. |
Remarks
selector
is not evaluated until enumeration. The value returned will be used to select a
sequence from sources
; enumeration will continue with items from that sequence.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|