summaryrefslogtreecommitdiff
path: root/external/rx/Rx/NET/Source/System.Reactive.Linq/Reactive/Linq/Observable.StandardSequenceOperators.cs
diff options
context:
space:
mode:
Diffstat (limited to 'external/rx/Rx/NET/Source/System.Reactive.Linq/Reactive/Linq/Observable.StandardSequenceOperators.cs')
-rw-r--r--external/rx/Rx/NET/Source/System.Reactive.Linq/Reactive/Linq/Observable.StandardSequenceOperators.cs367
1 files changed, 351 insertions, 16 deletions
diff --git a/external/rx/Rx/NET/Source/System.Reactive.Linq/Reactive/Linq/Observable.StandardSequenceOperators.cs b/external/rx/Rx/NET/Source/System.Reactive.Linq/Reactive/Linq/Observable.StandardSequenceOperators.cs
index 8eb9289864..803ba26094 100644
--- a/external/rx/Rx/NET/Source/System.Reactive.Linq/Reactive/Linq/Observable.StandardSequenceOperators.cs
+++ b/external/rx/Rx/NET/Source/System.Reactive.Linq/Reactive/Linq/Observable.StandardSequenceOperators.cs
@@ -241,6 +241,112 @@ namespace System.Reactive.Linq
return s_impl.GroupBy<TSource, TKey, TElement>(source, keySelector, elementSelector, comparer);
}
+ /// <summary>
+ /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function.
+ /// </summary>
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
+ /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
+ /// <param name="source">An observable sequence whose elements to group.</param>
+ /// <param name="keySelector">A function to extract the key for each element.</param>
+ /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
+ /// <returns>A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.</returns>
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> is null.</exception>
+ /// <exception cref="ArgumentOutOfRangeException"><paramref name="capacity"/> is less than 0.</exception>
+ public static IObservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, int capacity)
+ {
+ if (source == null)
+ throw new ArgumentNullException("source");
+ if (keySelector == null)
+ throw new ArgumentNullException("keySelector");
+ if (capacity < 0)
+ throw new ArgumentOutOfRangeException("capacity");
+
+ return s_impl.GroupBy<TSource, TKey>(source, keySelector, capacity);
+ }
+
+ /// <summary>
+ /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer.
+ /// </summary>
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
+ /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
+ /// <param name="source">An observable sequence whose elements to group.</param>
+ /// <param name="keySelector">A function to extract the key for each element.</param>
+ /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
+ /// <param name="comparer">An equality comparer to compare keys with.</param>
+ /// <returns>A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.</returns>
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="comparer"/> is null.</exception>
+ /// <exception cref="ArgumentOutOfRangeException"><paramref name="capacity"/> is less than 0.</exception>
+ public static IObservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, int capacity, IEqualityComparer<TKey> comparer)
+ {
+ if (source == null)
+ throw new ArgumentNullException("source");
+ if (keySelector == null)
+ throw new ArgumentNullException("keySelector");
+ if (capacity < 0)
+ throw new ArgumentOutOfRangeException("capacity");
+ if (comparer == null)
+ throw new ArgumentNullException("comparer");
+
+ return s_impl.GroupBy<TSource, TKey>(source, keySelector, capacity, comparer);
+ }
+
+ /// <summary>
+ /// Groups the elements of an observable sequence with the specified initial capacity and selects the resulting elements by using a specified function.
+ /// </summary>
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
+ /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
+ /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
+ /// <param name="source">An observable sequence whose elements to group.</param>
+ /// <param name="keySelector">A function to extract the key for each element.</param>
+ /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
+ /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
+ /// <returns>A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.</returns>
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="elementSelector"/> is null.</exception>
+ /// <exception cref="ArgumentOutOfRangeException"><paramref name="capacity"/> is less than 0.</exception>
+ public static IObservable<IGroupedObservable<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, int capacity)
+ {
+ if (source == null)
+ throw new ArgumentNullException("source");
+ if (keySelector == null)
+ throw new ArgumentNullException("keySelector");
+ if (elementSelector == null)
+ throw new ArgumentNullException("elementSelector");
+ if (capacity < 0)
+ throw new ArgumentOutOfRangeException("capacity");
+
+ return s_impl.GroupBy<TSource, TKey, TElement>(source, keySelector, elementSelector, capacity);
+ }
+
+ /// <summary>
+ /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer and selects the resulting elements by using a specified function.
+ /// </summary>
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
+ /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
+ /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
+ /// <param name="source">An observable sequence whose elements to group.</param>
+ /// <param name="keySelector">A function to extract the key for each element.</param>
+ /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
+ /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
+ /// <param name="comparer">An equality comparer to compare keys with.</param>
+ /// <returns>A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.</returns>
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="elementSelector"/> or <paramref name="comparer"/> is null.</exception>
+ /// <exception cref="ArgumentOutOfRangeException"><paramref name="capacity"/> is less than 0.</exception>
+ public static IObservable<IGroupedObservable<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, int capacity, IEqualityComparer<TKey> comparer)
+ {
+ if (source == null)
+ throw new ArgumentNullException("source");
+ if (keySelector == null)
+ throw new ArgumentNullException("keySelector");
+ if (elementSelector == null)
+ throw new ArgumentNullException("elementSelector");
+ if (capacity < 0)
+ throw new ArgumentOutOfRangeException("capacity");
+ if (comparer == null)
+ throw new ArgumentNullException("comparer");
+
+ return s_impl.GroupBy<TSource, TKey, TElement>(source, keySelector, elementSelector, capacity, comparer);
+ }
+
#endregion
#region + GroupByUntil +
@@ -329,7 +435,7 @@ namespace System.Reactive.Linq
/// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered.
/// </returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="durationSelector"/> or <paramref name="comparer"/> is null.</exception>
- public static IObservable<IGroupedObservable<TKey, TSource>> GroupByUntil<TSource, TKey, TDuration>(this IObservable<TSource> source, Func<TSource, TKey> keySelector,Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>> durationSelector, IEqualityComparer<TKey> comparer)
+ public static IObservable<IGroupedObservable<TKey, TSource>> GroupByUntil<TSource, TKey, TDuration>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>> durationSelector, IEqualityComparer<TKey> comparer)
{
if (source == null)
throw new ArgumentNullException("source");
@@ -371,6 +477,148 @@ namespace System.Reactive.Linq
return s_impl.GroupByUntil<TSource, TKey, TDuration>(source, keySelector, durationSelector);
}
+ /// <summary>
+ /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer and selects the resulting elements by using a specified function.
+ /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
+ /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
+ /// </summary>
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
+ /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
+ /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
+ /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
+ /// <param name="source">An observable sequence whose elements to group.</param>
+ /// <param name="keySelector">A function to extract the key for each element.</param>
+ /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
+ /// <param name="durationSelector">A function to signal the expiration of a group.</param>
+ /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
+ /// <param name="comparer">An equality comparer to compare keys with.</param>
+ /// <returns>
+ /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
+ /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encountered.
+ /// </returns>
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="elementSelector"/> or <paramref name="durationSelector"/> or <paramref name="comparer"/> is null.</exception>
+ /// <exception cref="ArgumentOutOfRangeException"><paramref name="capacity"/> is less than 0.</exception>
+ public static IObservable<IGroupedObservable<TKey, TElement>> GroupByUntil<TSource, TKey, TElement, TDuration>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>> durationSelector, int capacity, IEqualityComparer<TKey> comparer)
+ {
+ if (source == null)
+ throw new ArgumentNullException("source");
+ if (keySelector == null)
+ throw new ArgumentNullException("keySelector");
+ if (elementSelector == null)
+ throw new ArgumentNullException("elementSelector");
+ if (durationSelector == null)
+ throw new ArgumentNullException("durationSelector");
+ if (capacity < 0)
+ throw new ArgumentOutOfRangeException("capacity");
+ if (comparer == null)
+ throw new ArgumentNullException("comparer");
+
+ return s_impl.GroupByUntil<TSource, TKey, TElement, TDuration>(source, keySelector, elementSelector, durationSelector, capacity, comparer);
+ }
+
+ /// <summary>
+ /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and selects the resulting elements by using a specified function.
+ /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
+ /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
+ /// </summary>
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
+ /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
+ /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
+ /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
+ /// <param name="source">An observable sequence whose elements to group.</param>
+ /// <param name="keySelector">A function to extract the key for each element.</param>
+ /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
+ /// <param name="durationSelector">A function to signal the expiration of a group.</param>
+ /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
+ /// <returns>
+ /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
+ /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered.
+ /// </returns>
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="elementSelector"/> or <paramref name="durationSelector"/> is null.</exception>
+ /// <exception cref="ArgumentOutOfRangeException"><paramref name="capacity"/> is less than 0.</exception>
+ public static IObservable<IGroupedObservable<TKey, TElement>> GroupByUntil<TSource, TKey, TElement, TDuration>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>> durationSelector, int capacity)
+ {
+ if (source == null)
+ throw new ArgumentNullException("source");
+ if (keySelector == null)
+ throw new ArgumentNullException("keySelector");
+ if (elementSelector == null)
+ throw new ArgumentNullException("elementSelector");
+ if (durationSelector == null)
+ throw new ArgumentNullException("durationSelector");
+ if (capacity < 0)
+ throw new ArgumentOutOfRangeException("capacity");
+
+ return s_impl.GroupByUntil<TSource, TKey, TElement, TDuration>(source, keySelector, elementSelector, durationSelector, capacity);
+ }
+
+ /// <summary>
+ /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer.
+ /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
+ /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
+ /// </summary>
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
+ /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
+ /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
+ /// <param name="source">An observable sequence whose elements to group.</param>
+ /// <param name="keySelector">A function to extract the key for each element.</param>
+ /// <param name="durationSelector">A function to signal the expiration of a group.</param>
+ /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
+ /// <param name="comparer">An equality comparer to compare keys with.</param>
+ /// <returns>
+ /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
+ /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered.
+ /// </returns>
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="durationSelector"/> or <paramref name="comparer"/> is null.</exception>
+ /// <exception cref="ArgumentOutOfRangeException"><paramref name="capacity"/> is less than 0.</exception>
+ public static IObservable<IGroupedObservable<TKey, TSource>> GroupByUntil<TSource, TKey, TDuration>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>> durationSelector, int capacity, IEqualityComparer<TKey> comparer)
+ {
+ if (source == null)
+ throw new ArgumentNullException("source");
+ if (keySelector == null)
+ throw new ArgumentNullException("keySelector");
+ if (durationSelector == null)
+ throw new ArgumentNullException("durationSelector");
+ if (capacity < 0)
+ throw new ArgumentOutOfRangeException("capacity");
+ if (comparer == null)
+ throw new ArgumentNullException("comparer");
+
+ return s_impl.GroupByUntil<TSource, TKey, TDuration>(source, keySelector, durationSelector, capacity, comparer);
+ }
+
+ /// <summary>
+ /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function.
+ /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
+ /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
+ /// </summary>
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
+ /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
+ /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
+ /// <param name="source">An observable sequence whose elements to group.</param>
+ /// <param name="keySelector">A function to extract the key for each element.</param>
+ /// <param name="durationSelector">A function to signal the expiration of a group.</param>
+ /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
+ /// <returns>
+ /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
+ /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered.
+ /// </returns>
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="durationSelector"/> is null.</exception>
+ /// <exception cref="ArgumentOutOfRangeException"><paramref name="capacity"/> is less than 0.</exception>
+ public static IObservable<IGroupedObservable<TKey, TSource>> GroupByUntil<TSource, TKey, TDuration>(this IObservable<TSource> source, Func<TSource, TKey> keySelector, Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>> durationSelector, int capacity)
+ {
+ if (source == null)
+ throw new ArgumentNullException("source");
+ if (keySelector == null)
+ throw new ArgumentNullException("keySelector");
+ if (durationSelector == null)
+ throw new ArgumentNullException("durationSelector");
+ if (capacity < 0)
+ throw new ArgumentOutOfRangeException("capacity");
+
+ return s_impl.GroupByUntil<TSource, TKey, TDuration>(source, keySelector, durationSelector, capacity);
+ }
+
#endregion
#region + GroupJoin +
@@ -545,12 +793,12 @@ namespace System.Reactive.Linq
}
/// <summary>
- /// Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
+ /// Projects each element of an observable sequence to an observable sequence by incorporating the element's index and merges the resulting observable sequences into one observable sequence.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
/// <param name="source">An observable sequence of elements to project.</param>
- /// <param name="selector">A transform function to apply to each source element; the second parameter of the function represents the index of the source element.</param>
+ /// <param name="selector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
/// <returns>An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, int, IObservable<TResult>> selector)
@@ -585,6 +833,26 @@ namespace System.Reactive.Linq
}
/// <summary>
+ /// Projects each element of an observable sequence to a task by incorporating the element's index and merges all of the task results into one observable sequence.
+ /// </summary>
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
+ /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
+ /// <param name="source">An observable sequence of elements to project.</param>
+ /// <param name="selector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
+ /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
+ /// <remarks>This overload supports composition of observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using <see cref="TaskObservableExtensions.ToObservable&lt;TResult&gt;"/>.</remarks>
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
+ public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, int, Task<TResult>> selector)
+ {
+ if (source == null)
+ throw new ArgumentNullException("source");
+ if (selector == null)
+ throw new ArgumentNullException("selector");
+
+ return s_impl.SelectMany<TSource, TResult>(source, selector);
+ }
+
+ /// <summary>
/// Projects each element of an observable sequence to a task with cancellation support and merges all of the task results into one observable sequence.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
@@ -603,6 +871,26 @@ namespace System.Reactive.Linq
return s_impl.SelectMany<TSource, TResult>(source, selector);
}
+
+ /// <summary>
+ /// Projects each element of an observable sequence to a task by incorporating the element's index with cancellation support and merges all of the task results into one observable sequence.
+ /// </summary>
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
+ /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
+ /// <param name="source">An observable sequence of elements to project.</param>
+ /// <param name="selector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
+ /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
+ /// <remarks>This overload supports composition of observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using <see cref="TaskObservableExtensions.ToObservable&lt;TResult&gt;"/>.</remarks>
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
+ public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, int, CancellationToken, Task<TResult>> selector)
+ {
+ if (source == null)
+ throw new ArgumentNullException("source");
+ if (selector == null)
+ throw new ArgumentNullException("selector");
+
+ return s_impl.SelectMany<TSource, TResult>(source, selector);
+ }
#endif
/// <summary>
@@ -629,14 +917,14 @@ namespace System.Reactive.Linq
}
/// <summary>
- /// Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
+ /// Projects each element of an observable sequence to an observable sequence by incorporating the element's index, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <typeparam name="TCollection">The type of the elements in the projected intermediate sequences.</typeparam>
/// <typeparam name="TResult">The type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate sequence elements.</typeparam>
/// <param name="source">An observable sequence of elements to project.</param>
- /// <param name="collectionSelector">A transform function to apply to each source element; the second parameter of the function represents the index of the source element.</param>
- /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
+ /// <param name="collectionSelector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
+ /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence; the second parameter of the function represents the index of the source element and the fourth parameter represents the index of the intermediate element.</param>
/// <returns>An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="collectionSelector"/> or <paramref name="resultSelector"/> is null.</exception>
public static IObservable<TResult> SelectMany<TSource, TCollection, TResult>(this IObservable<TSource> source, Func<TSource, int, IObservable<TCollection>> collectionSelector, Func<TSource, int, TCollection, int, TResult> resultSelector)
@@ -677,6 +965,30 @@ namespace System.Reactive.Linq
}
/// <summary>
+ /// Projects each element of an observable sequence to a task by incorporating the element's index, invokes the result selector for the source element and the task result, and merges the results into one observable sequence.
+ /// </summary>
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
+ /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
+ /// <typeparam name="TResult">The type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate task results.</typeparam>
+ /// <param name="source">An observable sequence of elements to project.</param>
+ /// <param name="taskSelector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
+ /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence; the second parameter of the function represents the index of the source element.</param>
+ /// <returns>An observable sequence whose elements are the result of obtaining a task for each element of the input sequence and then mapping the task's result and its corresponding source element to a result element.</returns>
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="taskSelector"/> or <paramref name="resultSelector"/> is null.</exception>
+ /// <remarks>This overload supports using LINQ query comprehension syntax in C# and Visual Basic to compose observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using <see cref="TaskObservableExtensions.ToObservable&lt;TResult&gt;"/>.</remarks>
+ public static IObservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IObservable<TSource> source, Func<TSource, int, Task<TTaskResult>> taskSelector, Func<TSource, int, TTaskResult, TResult> resultSelector)
+ {
+ if (source == null)
+ throw new ArgumentNullException("source");
+ if (taskSelector == null)
+ throw new ArgumentNullException("taskSelector");
+ if (resultSelector == null)
+ throw new ArgumentNullException("resultSelector");
+
+ return s_impl.SelectMany<TSource, TTaskResult, TResult>(source, taskSelector, resultSelector);
+ }
+
+ /// <summary>
/// Projects each element of an observable sequence to a task with cancellation support, invokes the result selector for the source element and the task result, and merges the results into one observable sequence.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
@@ -699,6 +1011,30 @@ namespace System.Reactive.Linq
return s_impl.SelectMany<TSource, TTaskResult, TResult>(source, taskSelector, resultSelector);
}
+
+ /// <summary>
+ /// Projects each element of an observable sequence to a task by incorporating the element's index with cancellation support, invokes the result selector for the source element and the task result, and merges the results into one observable sequence.
+ /// </summary>
+ /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
+ /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
+ /// <typeparam name="TResult">The type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate task results.</typeparam>
+ /// <param name="source">An observable sequence of elements to project.</param>
+ /// <param name="taskSelector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
+ /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence; the second parameter of the function represents the index of the source element.</param>
+ /// <returns>An observable sequence whose elements are the result of obtaining a task for each element of the input sequence and then mapping the task's result and its corresponding source element to a result element.</returns>
+ /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="taskSelector"/> or <paramref name="resultSelector"/> is null.</exception>
+ /// <remarks>This overload supports using LINQ query comprehension syntax in C# and Visual Basic to compose observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using <see cref="TaskObservableExtensions.ToObservable&lt;TResult&gt;"/>.</remarks>
+ public static IObservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IObservable<TSource> source, Func<TSource, int, CancellationToken, Task<TTaskResult>> taskSelector, Func<TSource, int, TTaskResult, TResult> resultSelector)
+ {
+ if (source == null)
+ throw new ArgumentNullException("source");
+ if (taskSelector == null)
+ throw new ArgumentNullException("taskSelector");
+ if (resultSelector == null)
+ throw new ArgumentNullException("resultSelector");
+
+ return s_impl.SelectMany<TSource, TTaskResult, TResult>(source, taskSelector, resultSelector);
+ }
#endif
/// <summary>
@@ -727,17 +1063,17 @@ namespace System.Reactive.Linq
}
/// <summary>
- /// Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
+ /// Projects each notification of an observable sequence to an observable sequence by incorporating the element's index and merges the resulting observable sequences into one observable sequence.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
/// <param name="source">An observable sequence of notifications to project.</param>
- /// <param name="onNext">A transform function to apply to each element; the second parameter represents the index of the source element.</param>
- /// <param name="onError">A transform function to apply when an error occurs in the source sequence; the second parameter represents the index of the source element.</param>
- /// <param name="onCompleted">A transform function to apply when the end of the source sequence is reached; the second parameter represents the number of elements observed.</param>
+ /// <param name="onNext">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
+ /// <param name="onError">A transform function to apply when an error occurs in the source sequence.</param>
+ /// <param name="onCompleted">A transform function to apply when the end of the source sequence is reached.</param>
/// <returns>An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="onNext"/> or <paramref name="onError"/> or <paramref name="onCompleted"/> is null.</exception>
- public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, int, IObservable<TResult>> onNext, Func<Exception, int, IObservable<TResult>> onError, Func<int, IObservable<TResult>> onCompleted)
+ public static IObservable<TResult> SelectMany<TSource, TResult>(this IObservable<TSource> source, Func<TSource, int, IObservable<TResult>> onNext, Func<Exception, IObservable<TResult>> onError, Func<IObservable<TResult>> onCompleted)
{
if (source == null)
throw new ArgumentNullException("source");
@@ -772,13 +1108,12 @@ namespace System.Reactive.Linq
}
/// <summary>
- /// Projects each element of an observable sequence to an enumerable sequence and concatenates the resulting enumerable sequences into one observable sequence.
- /// The index of each source element is used in the projected form of that element.
+ /// Projects each element of an observable sequence to an enumerable sequence by incorporating the element's index and concatenates the resulting enumerable sequences into one observable sequence.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <typeparam name="TResult">The type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence.</typeparam>
/// <param name="source">An observable sequence of elements to project.</param>
- /// <param name="selector">A transform function to apply to each source element; the second parameter of the function represents the index of the source element.</param>
+ /// <param name="selector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
/// <returns>An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="selector"/> is null.</exception>
/// <remarks>The projected sequences are enumerated synchonously within the OnNext call of the source sequence. In order to do a concurrent, non-blocking merge, change the selector to return an observable sequence obtained using the <see cref="Observable.ToObservable&lt;TSource&gt;(IEnumerable&lt;TSource&gt;)"/> conversion.</remarks>
@@ -817,14 +1152,14 @@ namespace System.Reactive.Linq
}
/// <summary>
- /// Projects each element of an observable sequence to an enumerable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
+ /// Projects each element of an observable sequence to an enumerable sequence by incorporating the element's index, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
/// </summary>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <typeparam name="TCollection">The type of the elements in the projected intermediate enumerable sequences.</typeparam>
/// <typeparam name="TResult">The type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate sequence elements.</typeparam>
/// <param name="source">An observable sequence of elements to project.</param>
/// <param name="collectionSelector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
- /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
+ /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence; the second parameter of the function represents the index of the source element and the fourth parameter represents the index of the intermediate element.</param>
/// <returns>An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.</returns>
/// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="collectionSelector"/> or <paramref name="resultSelector"/> is null.</exception>
/// <remarks>The projected sequences are enumerated synchonously within the OnNext call of the source sequence. In order to do a concurrent, non-blocking merge, change the selector to return an observable sequence obtained using the <see cref="Observable.ToObservable&lt;TSource&gt;(IEnumerable&lt;TSource&gt;)"/> conversion.</remarks>