Refactor fluent download pipelines

This commit is contained in:
qwsdcvghyu89
2025-09-27 15:38:58 +10:00
parent 13c6fbaf5f
commit 94b6c0645c
33 changed files with 518 additions and 451 deletions
+28
View File
@@ -0,0 +1,28 @@
using aeqw89.DataKeys;
using Beam.Data;
using Beam.Downloaders;
using Beam.Dynamic;
using Beam.Models;
namespace Beam.Fluent;
public static class FluentDownload {
public static ITransformStage<RawType, OutType> Links<RawType, OutType>(params IEnumerable<string> links) {
return new TransformStage<RawType, OutType>(new DownloadContextBuilder<RawType>()
.WithLinks(links));
}
public static ITransformStage<RawType, OutType>
ResourceDefinition<RawType, OutType>(ResourceDefinition definition) {
if (definition.Location.States.Count == 0)
throw new ArgumentException(Exceptions.Exceptions.resource_definition_invalid_states_count, nameof(definition));
var linkGenerator = new OrderedLinkGenerator(definition.Location.Segments, (NumberedStateChanger)definition.Location.StateChanger.Behavior,
definition.Location.States.First().Copy());
return new TransformStage<RawType, OutType>(new DownloadContextBuilder<RawType>()
.WithLinks(StringEnumerable.FromGenerator(linkGenerator!)));
}
public static ITransformStage<RawType, OutType> FromContext<RawType, OutType>(DownloadContext<RawType> existing) {
return new TransformStage<RawType, OutType>(DownloadContextBuilder<RawType>.FromContext(existing));
}
}