Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikus1993 committed Jan 31, 2024
1 parent c864abf commit 58c30bd
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,17 @@ public XboxStoreGamesParser(ILogger<XboxStoreGamesParser> logger)
_logger = logger;
}

public async IAsyncEnumerable<XboxGame> Parse([EnumeratorCancellation] CancellationToken cancellationToken = default)
public IAsyncEnumerable<XboxGame> Parse(CancellationToken cancellationToken = default)
{
var pages = Enumerable.Range(0, Pages).Select(page => ParsePage(page + 1, cancellationToken)).ToArray();
await foreach (var game in AsyncEnumerableEx.Merge(pages).WithCancellation(cancellationToken))
var pages = ParsePages(Pages, cancellationToken).ToArray();
return AsyncEnumerableEx.Merge(pages);
}

private IEnumerable<IAsyncEnumerable<XboxGame>> ParsePages(int pages, CancellationToken cancellationToken = default)
{
for (int page = 1; page <= pages; page++)
{
yield return game;
yield return ParsePage(page, cancellationToken);
}
}

Expand Down

0 comments on commit 58c30bd

Please sign in to comment.