f52aa6123b
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.
36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
namespace Beam.Downloaders;
|
|
|
|
public sealed class FragmentOptionsBuilder {
|
|
private int? _fragmentSize;
|
|
private bool _downloadInParallel = false;
|
|
private int? _parallelThreads = null;
|
|
|
|
public FragmentOptionsBuilder WithFragmentSize(int bytes) {
|
|
if (bytes <= 0) throw new System.ArgumentOutOfRangeException(nameof(bytes));
|
|
_fragmentSize = bytes;
|
|
return this;
|
|
}
|
|
|
|
public FragmentOptionsBuilder WithDownloadInParallel(bool value = true) {
|
|
_downloadInParallel = value;
|
|
return this;
|
|
}
|
|
|
|
public FragmentOptionsBuilder WithParallelThreads(int? threads) {
|
|
if (threads.HasValue && threads.Value <= 0)
|
|
throw new System.ArgumentOutOfRangeException(nameof(threads));
|
|
_parallelThreads = threads;
|
|
return this;
|
|
}
|
|
|
|
public FragmentOptions Build() {
|
|
if (!_fragmentSize.HasValue)
|
|
throw new System.InvalidOperationException("FragmentSize must be provided.");
|
|
|
|
return new FragmentOptions {
|
|
FragmentSize = _fragmentSize.Value,
|
|
DownloadInParallel = _downloadInParallel,
|
|
ParallelThreads = _parallelThreads
|
|
};
|
|
}
|
|
} |