,System.Func{--0,--1},System.Collections.Generic.IEqualityComparer{--1},System.Threading.CancellationToken)} ,System.Func{--0,--1})} ,System.Func{--0,--1},System.Func{--0,--2},System.Collections.Generic.IEqualityComparer{--1},System.Threading.CancellationToken)} ,System.Func{--0,--1},System.Func{--0,--2})}
ObservableAsync.ToDictionaryAsync(IObservableAsync, Func, IEqualityComparer?, CancellationToken) method¶
Defined in
Type: ObservableAsync
Namespace: ReactiveUI.Extensions.Async
Assembly: ReactiveUI.Extensions.dll
Applies to
net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481
Overloads¶
- 1.
public static ValueTask<Dictionary<TKey, T>> ToDictionaryAsync<T, TKey>(this IObservableAsync<T> @this, Func<T, TKey> keySelector, IEqualityComparer<TKey>? comparer, CancellationToken cancellationToken) where TKey : notnull - 2.
public static ValueTask<Dictionary<TKey, T>> ToDictionaryAsync<T, TKey>(this IObservableAsync<T> @this, Func<T, TKey> keySelector) where TKey : notnull - 3.
public static ValueTask<Dictionary<TKey, TValue>> ToDictionaryAsync<T, TKey, TValue>(this IObservableAsync<T> @this, Func<T, TKey> keySelector, Func<T, TValue> elementSelector, IEqualityComparer<TKey>? comparer, CancellationToken cancellationToken) where TKey : notnull - 4.
public static ValueTask<Dictionary<TKey, TValue>> ToDictionaryAsync<T, TKey, TValue>(this IObservableAsync<T> @this, Func<T, TKey> keySelector, Func<T, TValue> elementSelector) where TKey : notnull
1. Overload¶
public static ValueTask<Dictionary<TKey, T>> ToDictionaryAsync<T, TKey>(this IObservableAsync<T> @this, Func<T, TKey> keySelector, IEqualityComparer<TKey>? comparer, CancellationToken cancellationToken) where TKey : notnull
Summary: Asynchronously creates a dictionary from the elements of the sequence, using the specified key selector function.
Type parameters
| Name | Description |
|---|---|
T | The type of elements in the source sequence. |
TKey | The type of the keys in the resulting dictionary. Must be non-nullable. |
Parameters
| Name | Type | Description |
|---|---|---|
this | [IObservableAsync | The source observable sequence. |
keySelector | Func | A function to extract a key from each element in the sequence. Cannot be null. |
comparer | IEqualityComparer | An optional equality comparer to compare keys. If null, the default equality comparer for the key type is used. |
cancellationToken | CancellationToken | A cancellation token that can be used to cancel the asynchronous operation. |
Returns: ValueTask
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if the keySelector parameter is null. |
2. Overload¶
public static ValueTask<Dictionary<TKey, T>> ToDictionaryAsync<T, TKey>(this IObservableAsync<T> @this, Func<T, TKey> keySelector) where TKey : notnull
Summary: Asynchronously creates a dictionary from the elements of the sequence, using the specified key selector function and the default equality comparer for the key type.
Type parameters
| Name | Description |
|---|---|
T | The type of elements in the source sequence. |
TKey | The type of the keys in the resulting dictionary. Must be non-nullable. |
Parameters
| Name | Type | Description |
|---|---|---|
this | [IObservableAsync | The source observable sequence. |
keySelector | Func | A function to extract a key from each element in the sequence. Cannot be null. |
Returns: ValueTask
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if the keySelector parameter is null. |
3. Overload¶
public static ValueTask<Dictionary<TKey, TValue>> ToDictionaryAsync<T, TKey, TValue>(this IObservableAsync<T> @this, Func<T, TKey> keySelector, Func<T, TValue> elementSelector, IEqualityComparer<TKey>? comparer, CancellationToken cancellationToken) where TKey : notnull
Summary: Asynchronously creates a dictionary from the elements of the sequence using the specified key and element selector functions.
Type parameters
| Name | Description |
|---|---|
T | The type of elements in the source sequence. |
TKey | The type of the keys in the resulting dictionary. Must be non-nullable. |
TValue | The type of the values in the resulting dictionary. |
Parameters
| Name | Type | Description |
|---|---|---|
this | [IObservableAsync | The source observable sequence. |
keySelector | Func | A function to extract a key from each element in the sequence. |
elementSelector | Func | A function to map each element in the sequence to a value in the resulting dictionary. |
comparer | IEqualityComparer | An optional equality comparer to compare keys. If null, the default equality comparer for the key type is used. |
cancellationToken | CancellationToken | A cancellation token that can be used to cancel the asynchronous operation. |
Returns: ValueTask
Remarks
If multiple elements produce the same key, an exception may be thrown. The operation is performed asynchronously and can be cancelled using the provided cancellation token.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if keySelector or elementSelector is null. |
4. Overload¶
public static ValueTask<Dictionary<TKey, TValue>> ToDictionaryAsync<T, TKey, TValue>(this IObservableAsync<T> @this, Func<T, TKey> keySelector, Func<T, TValue> elementSelector) where TKey : notnull
Summary: Asynchronously creates a dictionary from the elements of the sequence using the specified key and element selector functions, with the default equality comparer for the key type.
Type parameters
| Name | Description |
|---|---|
T | The type of elements in the source sequence. |
TKey | The type of the keys in the resulting dictionary. Must be non-nullable. |
TValue | The type of the values in the resulting dictionary. |
Parameters
| Name | Type | Description |
|---|---|---|
this | [IObservableAsync | The source observable sequence. |
keySelector | Func | A function to extract a key from each element in the sequence. |
elementSelector | Func | A function to map each element in the sequence to a value in the resulting dictionary. |
Returns: ValueTask
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if keySelector or elementSelector is null. |