Exemplo n.º 1
0
        public static IObservable <T> Take <T>(this IObservable <T> source, int count)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count");
            }

            if (count == 0)
            {
                return(Empty <T>());
            }

            // optimize .Take(count).Take(count)
            TakeObservable <T> take = source as TakeObservable <T>;

            if (take != null && take.scheduler == null)
            {
                return(take.Combine(count));
            }

            return(new TakeObservable <T>(source, count));
        }
Exemplo n.º 2
0
        public static IObservable <T> Take <T>(this IObservable <T> source, TimeSpan duration, IScheduler scheduler)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (scheduler == null)
            {
                throw new ArgumentNullException("scheduler");
            }

            // optimize .Take(duration).Take(duration)
            TakeObservable <T> take = source as TakeObservable <T>;

            if (take != null && take.scheduler == scheduler)
            {
                return(take.Combine(duration));
            }

            return(new TakeObservable <T>(source, duration, scheduler));
        }
Exemplo n.º 3
0
 public Take(TakeObservable <T> parent, IObserver <T> observer, IDisposable cancel) : base(observer, cancel)
 {
     this.rest = parent.count;
 }