using System.Collections.Concurrent; using System.Text.Json; namespace Beam.Fluent { public static partial class DownloadBuilder { private sealed class DownloadStage(DownloadEnumerable download) : IDownloadStage { private IAsyncEnumerable> _download = download; public DownloadEnumerable AsAsyncEnumerable() { return new DownloadEnumerable(_download.GetAsyncEnumerator()); } private async IAsyncEnumerable> _SaveToDirectory(string dir) { Directory.CreateDirectory(dir); await foreach(var download in _download) { await System.IO.File.WriteAllTextAsync(Path.Combine(dir, $"{Path.GetRandomFileName()}.{download.Order}.json"), JsonSerializer.Serialize(dir)); yield return download; } } public IDownloadStage SaveToDirectory(string dir) { _download = _SaveToDirectory(dir); return this; } public IDownloadStage SaveToFiles(IEnumerable files) { throw new NotImplementedException(); } public IDownloadStage SaveToMemory(ConcurrentBag bag) { throw new NotImplementedException(); } public void WaitForDownload() { throw new NotImplementedException(); } public Task WaitForDownloadAsync() { throw new NotImplementedException(); } } } }