Exemple #1
0
        public async ValueTask <IReadOnlyList <IndexEdge <TEntity> > > ToIndexEdgesAsync(
            int offset,
            CancellationToken cancellationToken)
        {
            var list = new List <IndexEdge <TEntity> >();

            using IAsyncCursor <TEntity> cursor = await _source
                                                  .ToCursorAsync(cancellationToken)
                                                  .ConfigureAwait(false);

            var index = offset;

            while (await cursor.MoveNextAsync(cancellationToken).ConfigureAwait(false))
            {
                foreach (TEntity item in cursor.Current)
                {
                    list.Add(IndexEdge <TEntity> .Create(item, index++));
                }
            }

            return(list);
        }