Refactor downloaders to use ByteDocument and add options builders
Replaces generic RawType with ByteDocument in downloaders and context classes, simplifying type usage. Adds builder classes for FailurePredicateOptions, FragmentOptions, SkipPredicateOptions, and UnitDownloaderOptions to improve configuration flexibility. Introduces DownloadTarget enum and SkipPredicate delegate for more granular download control. Refactors Fluent API interfaces and implementations to remove RawType generics and streamline usage. Adds Playwright and Stealth download strategies for extensibility.
This commit is contained in:
@@ -8,22 +8,22 @@ using Beam.Models;
|
||||
namespace Beam.Fluent;
|
||||
|
||||
public static class FluentDownload {
|
||||
public static ITransformStage<RawType, OutType> Links<RawType, OutType>(params IEnumerable<string> links) where RawType : IDocument {
|
||||
return new TransformStage<RawType, OutType>(new DownloadContextBuilder<RawType>()
|
||||
public static ITransformStage<OutType> Links<OutType>(params IEnumerable<string> links) {
|
||||
return new TransformStage<OutType>(new DownloadContextBuilder()
|
||||
.WithLinks(links));
|
||||
}
|
||||
|
||||
public static ITransformStage<RawType, OutType>
|
||||
ResourceDefinition<RawType, OutType>(ResourceDefinition definition) where RawType : IDocument {
|
||||
public static ITransformStage< OutType>
|
||||
ResourceDefinition< 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>()
|
||||
return new TransformStage< OutType>(new DownloadContextBuilder()
|
||||
.WithLinks(StringEnumerable.FromGenerator(linkGenerator!)));
|
||||
}
|
||||
|
||||
public static ITransformStage<RawType, OutType> FromContext<RawType, OutType>(DownloadContext<RawType> existing) where RawType : IDocument {
|
||||
return new TransformStage<RawType, OutType>(DownloadContextBuilder<RawType>.FromContext(existing));
|
||||
public static ITransformStage< OutType> FromContext< OutType>(DownloadContext existing) {
|
||||
return new TransformStage< OutType>(DownloadContextBuilder.FromContext(existing));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user