// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Reactive.Concurrency;
#if !NO_TPL
using System.Reactive.Threading.Tasks; // needed for doc comments
using System.Threading;
using System.Threading.Tasks;
#endif
namespace System.Reactive.Linq
{
    public static partial class Observable
    {
        #region + Cast +
        /// 
        /// Converts the elements of an observable sequence to the specified type.
        ///  
        /// The type to convert the elements in the source sequence to. 
        /// An observable sequence that contains each element of the source sequence converted to the specified type. 
        ///  Cast(this IObservable source)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            return s_impl.Cast(source);
        }
        #endregion
        #region + DefaultIfEmpty +
        /// 
        /// Returns the elements of the specified sequence or the type parameter's default value in a singleton sequence if the sequence is empty.
        ///  
        /// The type of the elements in the source sequence (if any), whose default value will be taken if the sequence is empty. 
        /// An observable sequence that contains the default value for the TSource type if the source is empty; otherwise, the elements of the source itself. 
        ///  DefaultIfEmpty(this IObservable source)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            return s_impl.DefaultIfEmpty(source);
        }
        /// 
        /// Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty.
        ///  
        /// The type of the elements in the source sequence (if any), and the specified default value which will be taken if the sequence is empty. 
        /// An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself. 
        ///  DefaultIfEmpty(this IObservable source, TSource defaultValue)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            return s_impl.DefaultIfEmpty(source, defaultValue);
        }
        #endregion
        #region + Distinct +
        /// 
        /// Returns an observable sequence that contains only distinct elements.
        ///  
        /// The type of the elements in the source sequence. 
        /// An observable sequence only containing the distinct elements from the source sequence. 
        /// Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large. 
        public static IObservable Distinct(this IObservable source)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            return s_impl.Distinct(source);
        }
        /// 
        /// Returns an observable sequence that contains only distinct elements according to the comparer.
        ///  
        /// The type of the elements in the source sequence. 
        /// An observable sequence only containing the distinct elements from the source sequence. 
        /// Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large. 
        public static IObservable Distinct(this IObservable source, IEqualityComparer comparer)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (comparer == null)
                throw new ArgumentNullException("comparer");
            return s_impl.Distinct(source, comparer);
        }
        /// 
        /// Returns an observable sequence that contains only distinct elements according to the keySelector.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the discriminator key computed for each element in the source sequence. 
        /// An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence. 
        /// Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large. 
        public static IObservable Distinct(this IObservable source, Func keySelector)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (keySelector == null)
                throw new ArgumentNullException("keySelector");
            return s_impl.Distinct(source, keySelector);
        }
        /// 
        /// Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the discriminator key computed for each element in the source sequence. 
        /// An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence. 
        /// Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large. 
        public static IObservable Distinct(this IObservable source, Func keySelector, IEqualityComparer comparer)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (keySelector == null)
                throw new ArgumentNullException("keySelector");
            if (comparer == null)
                throw new ArgumentNullException("comparer");
            return s_impl.Distinct(source, keySelector, comparer);
        }
        #endregion
        #region + GroupBy +
        /// 
        /// Groups the elements of an observable sequence according to a specified key selector function.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the grouping key computed for each element in the source sequence. 
        /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. 
        /// > GroupBy(this IObservable source, Func keySelector)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (keySelector == null)
                throw new ArgumentNullException("keySelector");
            return s_impl.GroupBy(source, keySelector);
        }
        /// 
        /// Groups the elements of an observable sequence according to a specified key selector function and comparer.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the grouping key computed for each element in the source sequence. 
        /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. 
        /// > GroupBy(this IObservable source, Func keySelector, IEqualityComparer comparer)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (keySelector == null)
                throw new ArgumentNullException("keySelector");
            if (comparer == null)
                throw new ArgumentNullException("comparer");
            return s_impl.GroupBy(source, keySelector, comparer);
        }
        /// 
        /// Groups the elements of an observable sequence and selects the resulting elements by using a specified function.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the grouping key computed for each element in the source sequence. 
        /// The type of the elements within the groups computed for each element in the source sequence. 
        /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. 
        /// > GroupBy(this IObservable source, Func keySelector, Func elementSelector)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (keySelector == null)
                throw new ArgumentNullException("keySelector");
            if (elementSelector == null)
                throw new ArgumentNullException("elementSelector");
            return s_impl.GroupBy(source, keySelector, elementSelector);
        }
        /// 
        /// Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the grouping key computed for each element in the source sequence. 
        /// The type of the elements within the groups computed for each element in the source sequence. 
        /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value. 
        /// > GroupBy(this IObservable source, Func keySelector, Func elementSelector, IEqualityComparer comparer)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (keySelector == null)
                throw new ArgumentNullException("keySelector");
            if (elementSelector == null)
                throw new ArgumentNullException("elementSelector");
            if (comparer == null)
                throw new ArgumentNullException("comparer");
            return s_impl.GroupBy(source, keySelector, elementSelector, comparer);
        }
        #endregion
        #region + GroupByUntil +
        /// 
        /// Groups the elements of an observable sequence 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.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the grouping key computed for each element in the source sequence. 
        /// The type of the elements within the groups computed for each element in the source sequence. 
        /// The type of the elements in the duration sequences obtained for each group to denote its lifetime. 
        /// 
        /// 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.
        ///  
        /// > GroupByUntil(this IObservable source, Func keySelector, Func elementSelector, Func, IObservable> durationSelector, IEqualityComparer 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 (comparer == null)
                throw new ArgumentNullException("comparer");
            return s_impl.GroupByUntil(source, keySelector, elementSelector, durationSelector, comparer);
        }
        /// 
        /// Groups the elements of an observable sequence 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.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the grouping key computed for each element in the source sequence. 
        /// The type of the elements within the groups computed for each element in the source sequence. 
        /// The type of the elements in the duration sequences obtained for each group to denote its lifetime. 
        /// 
        /// 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.
        ///  
        /// > GroupByUntil(this IObservable source, Func keySelector, Func elementSelector, Func, IObservable> durationSelector)
        {
            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");
            return s_impl.GroupByUntil(source, keySelector, elementSelector, durationSelector);
        }
        /// 
        /// Groups the elements of an observable sequence 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.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the grouping key computed for each element in the source sequence. 
        /// The type of the elements in the duration sequences obtained for each group to denote its lifetime. 
        /// 
        /// 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.
        ///  
        /// > GroupByUntil(this IObservable source, Func keySelector,Func, IObservable> durationSelector, IEqualityComparer comparer)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (keySelector == null)
                throw new ArgumentNullException("keySelector");
            if (durationSelector == null)
                throw new ArgumentNullException("durationSelector");
            if (comparer == null)
                throw new ArgumentNullException("comparer");
            return s_impl.GroupByUntil(source, keySelector, durationSelector, comparer);
        }
        /// 
        /// Groups the elements of an observable sequence 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.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the grouping key computed for each element in the source sequence. 
        /// The type of the elements in the duration sequences obtained for each group to denote its lifetime. 
        /// 
        /// 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.
        ///  
        /// > GroupByUntil(this IObservable source, Func keySelector, Func, IObservable> durationSelector)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (keySelector == null)
                throw new ArgumentNullException("keySelector");
            if (durationSelector == null)
                throw new ArgumentNullException("durationSelector");
            return s_impl.GroupByUntil(source, keySelector, durationSelector);
        }
        #endregion
        #region + GroupJoin +
        /// 
        /// Correlates the elements of two sequences based on overlapping durations, and groups the results.
        ///  
        /// The type of the elements in the left source sequence. 
        /// The type of the elements in the right source sequence. 
        /// The type of the elements in the duration sequence denoting the computed duration of each element in the left source sequence. 
        /// The type of the elements in the duration sequence denoting the computed duration of each element in the right source sequence. 
        /// The type of the elements in the result sequence, obtained by invoking the result selector function for source elements with overlapping duration. 
        /// An observable sequence that contains result elements computed from source elements that have an overlapping duration. 
        ///  GroupJoin(this IObservable left, IObservable right, Func> leftDurationSelector, Func> rightDurationSelector, Func, TResult> resultSelector)
        {
            if (left == null)
                throw new ArgumentNullException("left");
            if (right == null)
                throw new ArgumentNullException("right");
            if (leftDurationSelector == null)
                throw new ArgumentNullException("leftDurationSelector");
            if (rightDurationSelector == null)
                throw new ArgumentNullException("rightDurationSelector");
            if (resultSelector == null)
                throw new ArgumentNullException("resultSelector");
            return s_impl.GroupJoin(left, right, leftDurationSelector, rightDurationSelector, resultSelector);
        }
        #endregion
        #region + Join +
        /// 
        /// Correlates the elements of two sequences based on overlapping durations.
        ///  
        /// The type of the elements in the left source sequence. 
        /// The type of the elements in the right source sequence. 
        /// The type of the elements in the duration sequence denoting the computed duration of each element in the left source sequence. 
        /// The type of the elements in the duration sequence denoting the computed duration of each element in the right source sequence. 
        /// The type of the elements in the result sequence, obtained by invoking the result selector function for source elements with overlapping duration. 
        /// An observable sequence that contains result elements computed from source elements that have an overlapping duration. 
        ///  Join(this IObservable left, IObservable right, Func> leftDurationSelector, Func> rightDurationSelector, Func resultSelector)
        {
            if (left == null)
                throw new ArgumentNullException("left");
            if (right == null)
                throw new ArgumentNullException("right");
            if (leftDurationSelector == null)
                throw new ArgumentNullException("leftDurationSelector");
            if (rightDurationSelector == null)
                throw new ArgumentNullException("rightDurationSelector");
            if (resultSelector == null)
                throw new ArgumentNullException("resultSelector");
            return s_impl.Join(left, right, leftDurationSelector, rightDurationSelector, resultSelector);
        }
        #endregion
        #region + OfType +
        /// 
        /// Filters the elements of an observable sequence based on the specified type.
        ///  
        /// The type to filter the elements in the source sequence on. 
        /// An observable sequence that contains elements from the input sequence of type TResult. 
        ///  OfType(this IObservable source)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            return s_impl.OfType(source);
        }
        #endregion
        #region + Select +
        /// 
        /// Projects each element of an observable sequence into a new form.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the elements in the result sequence, obtained by running the selector function for each element in the source sequence. 
        /// An observable sequence whose elements are the result of invoking the transform function on each element of source. 
        ///  Select(this IObservable source, Func selector)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (selector == null)
                throw new ArgumentNullException("selector");
            return s_impl.Select(source, selector);
        }
        /// 
        /// Projects each element of an observable sequence into a new form by incorporating the element's index.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the elements in the result sequence, obtained by running the selector function for each element in the source sequence. 
        /// An observable sequence whose elements are the result of invoking the transform function on each element of source. 
        ///  Select(this IObservable source, Func selector)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (selector == null)
                throw new ArgumentNullException("selector");
            return s_impl.Select(source, selector);
        }
        #endregion
        #region + SelectMany +
        /// 
        /// Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the elements in the other sequence and the elements in the result sequence. 
        /// An observable sequence whose elements are the result of projecting each source element onto the other sequence and merging all the resulting sequences together. 
        ///  SelectMany(this IObservable source, IObservable other)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (other == null)
                throw new ArgumentNullException("other");
            return s_impl.SelectMany(source, other);
        }
        /// 
        /// Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the elements in the projected inner sequences and the elements in the merged result sequence. 
        /// An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence. 
        ///  SelectMany(this IObservable source, Func> selector)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (selector == null)
                throw new ArgumentNullException("selector");
            return s_impl.SelectMany(source, selector);
        }
        /// 
        /// Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the elements in the projected inner sequences and the elements in the merged result sequence. 
        /// An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence. 
        ///  SelectMany(this IObservable source, Func> selector)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (selector == null)
                throw new ArgumentNullException("selector");
            return s_impl.SelectMany(source, selector);
        }
#if !NO_TPL
        /// 
        /// Projects each element of an observable sequence to a task and merges all of the task results into one observable sequence.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the result produced by the projected tasks and the elements in the merged result sequence. 
        /// An observable sequence whose elements are the result of the tasks executed for each element of the input sequence. 
        /// This overload supports composition of observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using  
        ///  SelectMany(this IObservable source, Func> selector)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (selector == null)
                throw new ArgumentNullException("selector");
            return s_impl.SelectMany(source, selector);
        }
        /// 
        /// Projects each element of an observable sequence to a task with cancellation support and merges all of the task results into one observable sequence.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the result produced by the projected tasks and the elements in the merged result sequence. 
        /// An observable sequence whose elements are the result of the tasks executed for each element of the input sequence. 
        /// This overload supports composition of observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using  
        ///  SelectMany(this IObservable source, Func> selector)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (selector == null)
                throw new ArgumentNullException("selector");
            return s_impl.SelectMany(source, selector);
        }
#endif
        /// 
        /// 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.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the elements in the projected intermediate sequences. 
        /// 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. 
        /// 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. 
        ///  SelectMany(this IObservable source, Func> collectionSelector, Func resultSelector)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (collectionSelector == null)
                throw new ArgumentNullException("collectionSelector");
            if (resultSelector == null)
                throw new ArgumentNullException("resultSelector");
            return s_impl.SelectMany(source, collectionSelector, resultSelector);
        }
        /// 
        /// 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.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the elements in the projected intermediate sequences. 
        /// 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. 
        /// 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. 
        ///  SelectMany(this IObservable source, Func> collectionSelector, Func resultSelector)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (collectionSelector == null)
                throw new ArgumentNullException("collectionSelector");
            if (resultSelector == null)
                throw new ArgumentNullException("resultSelector");
            return s_impl.SelectMany(source, collectionSelector, resultSelector);
        }
#if !NO_TPL
        /// 
        /// Projects each element of an observable sequence to a task, invokes the result selector for the source element and the task result, and merges the results into one observable sequence.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the results produced by the projected intermediate tasks. 
        /// 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. 
        /// 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. 
        /// 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  
        public static IObservable SelectMany(this IObservable source, Func> taskSelector, Func 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(source, taskSelector, resultSelector);
        }
        /// 
        /// 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.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the results produced by the projected intermediate tasks. 
        /// 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. 
        /// 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. 
        /// 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  
        public static IObservable SelectMany(this IObservable source, Func> taskSelector, Func 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(source, taskSelector, resultSelector);
        }
#endif
        /// 
        /// Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the elements in the projected inner sequences and the elements in the merged result sequence. 
        /// An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. 
        ///  SelectMany(this IObservable source, Func> onNext, Func> onError, Func> onCompleted)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (onNext == null)
                throw new ArgumentNullException("onNext");
            if (onError == null)
                throw new ArgumentNullException("onError");
            if (onCompleted == null)
                throw new ArgumentNullException("onCompleted");
            return s_impl.SelectMany(source, onNext, onError, onCompleted);
        }
        /// 
        /// Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the elements in the projected inner sequences and the elements in the merged result sequence. 
        /// An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. 
        ///  SelectMany(this IObservable source, Func> onNext, Func> onError, Func> onCompleted)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (onNext == null)
                throw new ArgumentNullException("onNext");
            if (onError == null)
                throw new ArgumentNullException("onError");
            if (onCompleted == null)
                throw new ArgumentNullException("onCompleted");
            return s_impl.SelectMany(source, onNext, onError, onCompleted);
        }
        /// 
        /// Projects each element of an observable sequence to an enumerable sequence and concatenates the resulting enumerable sequences into one observable sequence.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence. 
        /// An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence. 
        /// 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  
        public static IObservable SelectMany(this IObservable source, Func> selector)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (selector == null)
                throw new ArgumentNullException("selector");
            return s_impl.SelectMany(source, selector);
        }
        /// 
        /// 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. 
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence. 
        /// An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence. 
        /// 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  
        public static IObservable SelectMany(this IObservable source, Func> selector)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (selector == null)
                throw new ArgumentNullException("selector");
            return s_impl.SelectMany(source, selector);
        }
        /// 
        /// 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.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the elements in the projected intermediate enumerable sequences. 
        /// 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. 
        /// 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. 
        /// 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  
        public static IObservable SelectMany(this IObservable source, Func> collectionSelector, Func resultSelector)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (collectionSelector == null)
                throw new ArgumentNullException("collectionSelector");
            if (resultSelector == null)
                throw new ArgumentNullException("resultSelector");
            return s_impl.SelectMany(source, collectionSelector, resultSelector);
        }
        /// 
        /// 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.
        ///  
        /// The type of the elements in the source sequence. 
        /// The type of the elements in the projected intermediate enumerable sequences. 
        /// 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. 
        /// 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. 
        /// 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  
        public static IObservable SelectMany(this IObservable source, Func> collectionSelector, Func resultSelector)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (collectionSelector == null)
                throw new ArgumentNullException("collectionSelector");
            if (resultSelector == null)
                throw new ArgumentNullException("resultSelector");
            return s_impl.SelectMany(source, collectionSelector, resultSelector);
        }
        #endregion
        #region + Skip +
        /// 
        /// Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.
        ///  
        /// The type of the elements in the source sequence. 
        /// An observable sequence that contains the elements that occur after the specified index in the input sequence. 
        ///  Skip(this IObservable source, int count)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (count < 0)
                throw new ArgumentOutOfRangeException("count");
            return s_impl.Skip(source, count);
        }
        #endregion
        #region + SkipWhile +
        /// 
        /// Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
        ///  
        /// The type of the elements in the source sequence. 
        /// An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate. 
        ///  SkipWhile(this IObservable source, Func predicate)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (predicate == null)
                throw new ArgumentNullException("predicate");
            return s_impl.SkipWhile(source, predicate);
        }
        /// 
        /// Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
        /// The element's index is used in the logic of the predicate function.
        ///  
        /// The type of the elements in the source sequence. 
        /// An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate. 
        ///  SkipWhile(this IObservable source, Func predicate)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (predicate == null)
                throw new ArgumentNullException("predicate");
            return s_impl.SkipWhile(source, predicate);
        }
        #endregion
        #region + Take +
        /// 
        /// Returns a specified number of contiguous elements from the start of an observable sequence.
        ///  
        /// The type of the elements in the source sequence. 
        /// An observable sequence that contains the specified number of elements from the start of the input sequence. 
        ///  Take(this IObservable source, int count)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (count < 0)
                throw new ArgumentOutOfRangeException("count");
            return s_impl.Take(source, count);
        }
        /// 
        /// Returns a specified number of contiguous elements from the start of an observable sequence, using the specified scheduler for the edge case of Take(0).
        ///  
        /// The type of the elements in the source sequence. 
        /// count  is set to 0.
        /// An observable sequence that contains the specified number of elements from the start of the input sequence. 
        ///  Take(this IObservable source, int count, IScheduler scheduler)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (count < 0)
                throw new ArgumentOutOfRangeException("count");
            if (scheduler == null)
                throw new ArgumentNullException("scheduler");
            return s_impl.Take(source, count, scheduler);
        }
        #endregion
        #region + TakeWhile +
        /// 
        /// Returns elements from an observable sequence as long as a specified condition is true.
        ///  
        /// The type of the elements in the source sequence. 
        /// An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes. 
        ///  TakeWhile(this IObservable source, Func predicate)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (predicate == null)
                throw new ArgumentNullException("predicate");
            return s_impl.TakeWhile(source, predicate);
        }
        /// 
        /// Returns elements from an observable sequence as long as a specified condition is true.
        /// The element's index is used in the logic of the predicate function.
        ///  
        /// The type of the elements in the source sequence. 
        /// An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes. 
        ///  TakeWhile(this IObservable source, Func predicate)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (predicate == null)
                throw new ArgumentNullException("predicate");
            return s_impl.TakeWhile(source, predicate);
        }
        #endregion
        #region + Where +
        /// 
        /// Filters the elements of an observable sequence based on a predicate.
        ///  
        /// The type of the elements in the source sequence. 
        /// An observable sequence that contains elements from the input sequence that satisfy the condition. 
        ///  Where(this IObservable source, Func predicate)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (predicate == null)
                throw new ArgumentNullException("predicate");
            return s_impl.Where(source, predicate);
        }
        /// 
        /// Filters the elements of an observable sequence based on a predicate by incorporating the element's index.
        ///  
        /// The type of the elements in the source sequence. 
        /// An observable sequence that contains elements from the input sequence that satisfy the condition. 
        ///  Where(this IObservable source, Func predicate)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (predicate == null)
                throw new ArgumentNullException("predicate");
            return s_impl.Where(source, predicate);
        }
        #endregion
    }
}