Ejemplo n.º 1
0
        public static async Task ForEachAsync <T>(this IAsyncFastEnumerable <T> source, Func <T, Task> next)
        {
            var e = source.GetAsyncEnumerator();

            try
            {
                while (await e.WaitForNextAsync().ConfigureAwait(false))
                {
                    while (true)
                    {
                        var item = e.TryGetNext(out var success);

                        if (!success)
                        {
                            break;
                        }

                        await next(item).ConfigureAwait(false);
                    }
                }
            }
            finally
            {
                await e.DisposeAsync().ConfigureAwait(false);
            }
        }
Ejemplo n.º 2
0
        public static async Task <R> Aggregate <T, R>(this IAsyncFastEnumerable <T> source, R seed, Func <R, T, Task <R> > aggregate)
        {
            var res = seed;

            var e = source.GetAsyncEnumerator();

            try
            {
                while (await e.WaitForNextAsync().ConfigureAwait(false))
                {
                    while (true)
                    {
                        var item = e.TryGetNext(out var success);

                        if (!success)
                        {
                            break;
                        }

                        res = await aggregate(res, item).ConfigureAwait(false);
                    }
                }
            }
            finally
            {
                await e.DisposeAsync().ConfigureAwait(false);
            }

            return(res);
        }
Ejemplo n.º 3
0
 public WhereFastIteratorWithTask(IAsyncFastEnumerable <T> source, Func <T, Task <bool> > predicate)
 {
     _source    = source;
     _predicate = predicate;
 }
Ejemplo n.º 4
0
 public WhereFastIterator(IAsyncFastEnumerable <T> source, Func <T, bool> predicate)
 {
     _source    = source;
     _predicate = predicate;
 }
Ejemplo n.º 5
0
 public SelectFastIteratorWithTask(IAsyncFastEnumerable <T> source, Func <T, Task <R> > selector)
 {
     _source   = source;
     _selector = selector;
 }
Ejemplo n.º 6
0
 public SelectFastIterator(IAsyncFastEnumerable <T> source, Func <T, R> selector)
 {
     _source   = source;
     _selector = selector;
 }
Ejemplo n.º 7
0
 public AsyncFastEnumerableToAsyncEnumerable(IAsyncFastEnumerable <T> source)
 {
     _source = source;
 }
Ejemplo n.º 8
0
 public static IAsyncFastEnumerable <T> Where <T>(this IAsyncFastEnumerable <T> source, Func <T, Task <bool> > predicate) => new WhereFastIteratorWithTask <T>(source, predicate);
Ejemplo n.º 9
0
 public static IAsyncEnumerable <T> ToAsyncEnumerable <T>(this IAsyncFastEnumerable <T> source) => new AsyncFastEnumerableToAsyncEnumerable <T>(source);
Ejemplo n.º 10
0
 public static IAsyncFastEnumerable <R> Select <T, R>(this IAsyncFastEnumerable <T> source, Func <T, Task <R> > selector) => new SelectFastIteratorWithTask <T, R>(source, selector);