// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information. 
using System.Collections.Generic;
using System.Reactive.Concurrency;
namespace System.Reactive.Linq
{
    public static partial class Observable
    {
        #region + Subscribe +
        /// 
        /// Subscribes an observer to an enumerable sequence.
        /// 
        /// The type of the elements in the source sequence.
        /// Enumerable sequence to subscribe to.
        /// Observer that will receive notifications from the enumerable sequence.
        /// Disposable object that can be used to unsubscribe the observer from the enumerable
        ///  or  is null.
        public static IDisposable Subscribe(this IEnumerable source, IObserver observer)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (observer == null)
                throw new ArgumentNullException("observer");
            return s_impl.Subscribe(source, observer);
        }
        /// 
        /// Subscribes an observer to an enumerable sequence, using the specified scheduler to run the enumeration loop.
        /// 
        /// The type of the elements in the source sequence.
        /// Enumerable sequence to subscribe to.
        /// Observer that will receive notifications from the enumerable sequence.
        /// Scheduler to perform the enumeration on.
        /// Disposable object that can be used to unsubscribe the observer from the enumerable
        ///  or  or  is null.
        public static IDisposable Subscribe(this IEnumerable source, IObserver observer, IScheduler scheduler)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (observer == null)
                throw new ArgumentNullException("observer");
            if (scheduler == null)
                throw new ArgumentNullException("scheduler");
            return s_impl.Subscribe(source, observer, scheduler);
        }
        #endregion
        #region + ToEnumerable +
        /// 
        /// Converts an observable sequence to an enumerable sequence.
        /// 
        /// The type of the elements in the source sequence.
        /// An observable sequence to convert to an enumerable sequence.
        /// The enumerable sequence containing the elements in the observable sequence.
        ///  is null.
        public static IEnumerable ToEnumerable(this IObservable source)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            return s_impl.ToEnumerable(source);
        }
        #endregion
        #region ToEvent
        /// 
        /// Exposes an observable sequence as an object with an Action-based .NET event.
        /// 
        /// Observable source sequence.
        /// The event source object.
        ///  is null.
        public static IEventSource ToEvent(this IObservable source)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            return s_impl.ToEvent(source);
        }
        /// 
        /// Exposes an observable sequence as an object with an Action<TSource>-based .NET event.
        /// 
        /// The type of the elements in the source sequence.
        /// Observable source sequence.
        /// The event source object.
        ///  is null.
        public static IEventSource ToEvent(this IObservable source)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            return s_impl.ToEvent(source);
        }
        #endregion
        #region ToEventPattern
        /// 
        /// Exposes an observable sequence as an object with a .NET event, conforming to the standard .NET event pattern.
        /// 
        /// The type of the event data generated by the event.
        /// Observable source sequence.
        /// The event source object.
        ///  is null.
        public static IEventPatternSource ToEventPattern(this IObservable> source)
#if !NO_EVENTARGS_CONSTRAINT
            where TEventArgs : EventArgs
#endif
        {
            if (source == null)
                throw new ArgumentNullException("source");
            return s_impl.ToEventPattern(source);
        }
        #endregion
        #region + ToObservable +
        /// 
        /// Converts an enumerable sequence to an observable sequence.
        /// 
        /// The type of the elements in the source sequence.
        /// Enumerable sequence to convert to an observable sequence.
        /// The observable sequence whose elements are pulled from the given enumerable sequence.
        ///  is null.
        public static IObservable ToObservable(this IEnumerable source)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            return s_impl.ToObservable(source);
        }
        /// 
        /// Converts an enumerable sequence to an observable sequence, using the specified scheduler to run the enumeration loop.
        /// 
        /// The type of the elements in the source sequence.
        /// Enumerable sequence to convert to an observable sequence.
        /// Scheduler to run the enumeration of the input sequence on.
        /// The observable sequence whose elements are pulled from the given enumerable sequence.
        ///  or  is null.
        public static IObservable ToObservable(this IEnumerable source, IScheduler scheduler)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (scheduler == null)
                throw new ArgumentNullException("scheduler");
            return s_impl.ToObservable(source, scheduler);
        }
        #endregion
    }
}