Refactor downloaders to use generic options and unify logic

Replaces specialized binary and HTML downloaders with a generic, options-driven UnitDownloader and UnitFragmentDownloader pattern. Introduces UnitDownloaderOptions and builder classes for flexible configuration, updates interfaces and method signatures to support progress reporting, and removes redundant binary-specific classes. Updates Playwright and Stealth downloaders to use the new generic base, and adds improved error handling and reporting. Also updates dependency versions and makes minor API consistency improvements across the Fluent and Models layers.
This commit is contained in:
qwsdcvghyu89
2025-09-29 21:27:56 +10:00
parent 8e60109f5e
commit 2958a26e4f
30 changed files with 621 additions and 422 deletions
+13 -4
View File
@@ -1,15 +1,24 @@
using System.Text;
namespace Beam.Models {
public class ByteDocument(string filename, byte[] content, Encoding? encoding = null) : Document(filename, encoding) {
public byte[] Content { get; set; } = content;
public class ByteDocument : Document {
public ByteDocument(string filename, byte[] content, Encoding? encoding = null) : base(filename, encoding) {
Content = content;
}
public ByteDocument(string filename, Memory<byte> content, Encoding? encoding = null) :
base(filename, encoding) {
Content = content;
}
public Memory<byte> Content { get; set; }
public override byte[] ToBytes() {
return Content;
return Content.ToArray();
}
public override string ToString() {
return Encoding.GetString(Content);
return Encoding.GetString(Content.ToArray());
}
}
}