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); } }
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); }
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)); } }