예제 #1
0
        public static IEnumerable <T> Create <T>(TryTake <T> tryTake)
        {
            if (tryTake == null)
            {
                throw new ArgumentNullException("tryTake");
            }
            T item;

            while (tryTake.Invoke(out item))
            {
                yield return(item);
            }
        }
예제 #2
0
 public bool TryTake(out T item)
 {
     if (_tryTake != null)
     {
         if (_tryTake.Invoke(out item))
         {
             return(true);
         }
         if (_done)
         {
             Close();
         }
         return(false);
     }
     item = default(T);
     return(false);
 }
예제 #3
0
        public static IEnumerable <TResult> Create <TState, TResult>(TryTake <TState> tryTake, Func <TState, TResult> converter)
        {
            if (tryTake == null)
            {
                throw new ArgumentNullException("tryTake");
            }
            if (converter == null)
            {
                throw new ArgumentNullException("converter");
            }
            TState item;

            while (tryTake.Invoke(out item))
            {
                yield return(converter.Invoke(item));
            }
        }