Files
Beam/Beam.Fluent/DownloadBuilder.DownloadStage.cs
qwsdcvghyu89 a7d148a96f Introduce Beam.Fluent and Beam.Models projects
Added new Beam.Fluent and Beam.Models projects with staged download builder and data context models. Refactored and moved model classes from Beam.Temporary.Cli to Beam.Models. Added new data providers and extended DataBindings in Beam.Dynamic. Renamed Beam.Puppeteer to Beam.Playwright and updated related classes. Updated project references and package versions. Removed obsolete and unused files from Beam.Temporary.Cli.
2025-09-18 18:32:25 +10:00

44 lines
1.6 KiB
C#

using System.Collections.Concurrent;
using System.Text.Json;
namespace Beam.Fluent {
public static partial class DownloadBuilder<RawType, OutType> {
private sealed class DownloadStage(DownloadEnumerable<OutType> download) : IDownloadStage {
private IAsyncEnumerable<Ordered<OutType>> _download = download;
public DownloadEnumerable<OutType> AsAsyncEnumerable() {
return new DownloadEnumerable<OutType>(_download.GetAsyncEnumerator());
}
private async IAsyncEnumerable<Ordered<OutType>> _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<string> files) {
throw new NotImplementedException();
}
public IDownloadStage SaveToMemory(ConcurrentBag<OutType> bag) {
throw new NotImplementedException();
}
public void WaitForDownload() {
throw new NotImplementedException();
}
public Task WaitForDownloadAsync() {
throw new NotImplementedException();
}
}
}
}