using aeqw89.DataKeys; using Beam.Abstractions; using Beam.Data; using Beam.Downloaders; using Beam.Dynamic; using Beam.Models; namespace Beam.Fluent; public static class FluentDownload { public static ITransformStage Links(params IEnumerable links) where RawType : IDocument { return new TransformStage(new DownloadContextBuilder() .WithLinks(links)); } public static ITransformStage ResourceDefinition(ResourceDefinition definition) where RawType : IDocument { 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(new DownloadContextBuilder() .WithLinks(StringEnumerable.FromGenerator(linkGenerator!))); } public static ITransformStage FromContext(DownloadContext existing) where RawType : IDocument { return new TransformStage(DownloadContextBuilder.FromContext(existing)); } }