예제 #1
0
        public IDisposable Subscribe(IObserver <T> observer)
        {
            if (maxConcurrency == int.MaxValue)
            {
                var srcs = sources;
                var n    = sources.Length;

                var parent = new MergeAllCoordinator(observer, n, delayErrors);

                if (n != 0)
                {
                    parent.Subscribe(srcs, n);
                }
                else
                {
                    parent.Drain();
                }

                return(parent);
            }
            else
            {
                var parent = new MergeLimitedCoordinator(observer, sources, delayErrors, maxConcurrency);
                parent.Drain();
                return(parent);
            }
        }
        public IDisposable Subscribe(IObserver <T> observer)
        {
            var en = default(IEnumerator <IMaybeSource <T> >);

            try
            {
                en = RequireNonNullRef(sources.GetEnumerator(), "The GetEnumerator returned a null IEnumerator");
            }
            catch (Exception ex)
            {
                observer.OnError(ex);
                return(DisposableHelper.EMPTY);
            }

            if (maxConcurrency == int.MaxValue)
            {
                var parent = new MergeAllCoordinator(observer, delayErrors);

                parent.Subscribe(en);

                return(parent);
            }
            else
            {
                var parent = new MergeLimitedCoordinator(observer, en, delayErrors, maxConcurrency);
                parent.Drain();
                return(parent);
            }
        }