Ejemplo n.º 1
0
        public static async Task ForEach <T>(this ITaskEnumerable <T> source, Action <T, ITaskForEachController> action)
        {
            if (source == null || action == null)
            {
                return;
            }

            var controller = new TaskForEachController();

            using (var iterator = source.GetEnumerator())
            {
                while (iterator.MoveNext())
                {
                    if (controller.CheckContinue())
                    {
                        continue;
                    }

                    var item = await iterator.Current;
                    action(await iterator.Current, controller);

                    if (controller.CheckBreak())
                    {
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public static ITaskEnumerable <T> Map <T>(this ITaskEnumerable <ITaskEnumerable <T> > source)
 {
     if (source == null)
     {
         return(Empty <T>());
     }
     return(new MappedTaskEnumerable <T>(source));
 }
Ejemplo n.º 3
0
 public static ITaskEnumerable <TResult> Continue <TSource, TResult>(this ITaskEnumerable <TSource> source, Func <Task <TSource>, Task <TResult> > continuation)
 {
     if (source == null || continuation == null)
     {
         return(Empty <TResult>());
     }
     return(new ContinueTaskEnumerable <TSource, TResult>(source, continuation));
 }
Ejemplo n.º 4
0
 public MappedTaskEnumerable(ITaskEnumerable <ITaskEnumerable <T> > source)
 {
     this.source = source ?? throw new ArgumentNullException(nameof(source));
 }
Ejemplo n.º 5
0
 public ContinueTaskEnumerable(ITaskEnumerable <TSource> source, Func <Task <TSource>, Task <TResult> > continuation)
 {
     this.source       = source ?? throw new ArgumentNullException(nameof(source));
     this.continuation = continuation ?? throw new ArgumentNullException(nameof(continuation));
 }