056e426572
Updated project files for `Beam.Dynamic`, `Beam.Exports`, `Beam.Puppeteer`, `Beam.Temporary.Cli`, and `Beam` to include new XML headers, reorganize property groups, and add project references. Modified `PuppetedUnitDownloader` to support additional parameters for async transformers. Changed return types in `CommonTransformers` to `AsyncTransformer` for asynchronous processing. Significant refactoring in `DownloadBuilder`, `DownloadContext`, and `DownloadContextBuilder` to introduce generic parameters and improve context management. Updated `SequentialDownloader`, `SequentialFragmentDownloader`, and `UnitDownloader` to accommodate new async transformer types. Introduced `TypeExtensions` for unique type name generation and added `UnitFragmentDownloaderBinary` for handling binary downloads. Updated solution file to include the new `aeqw89.Beam` project, ensuring proper references across the solution. These changes enhance the asynchronous capabilities of the Beam library, improve type safety, and streamline the downloading process.
36 lines
1.6 KiB
C#
36 lines
1.6 KiB
C#
using aeqw89.DataKeys;
|
|
using Beam.Dynamic;
|
|
using HtmlAgilityPack;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Beam.Temporary.Cli {
|
|
public static class CommonTransformers {
|
|
public static AsyncTransformer<HtmlDocument, IDocumentMetaData> ArticleDataTransformer(DataBindings? binding) => (x) => {
|
|
return Task.FromResult<IDocumentMetaData>(new ArticleData() {
|
|
Authors = [OnlineCleaner.Clean(binding?.Authors?.Resolve(x) ?? "")],
|
|
Name = OnlineCleaner.Clean(binding?.Title?.ResolveString(x) ?? ""),
|
|
Categories = OnlineCleaner.Clean(binding?.Tags?.ResolveString(x) ?? "").Split(';') ?? [],
|
|
Description = OnlineCleaner.Clean(binding?.Description?.ResolveString(x) ?? "")
|
|
});
|
|
};
|
|
|
|
public static AsyncTransformer<HtmlDocument, IDocument> DocumentTransformer(DataBindings? binding, IDocumentMetaData? metaData = null) => (x) => {
|
|
var resolved = binding?.Resolve(x);
|
|
var articleData = new ArticleData() {
|
|
Name = OnlineCleaner.Clean(resolved?.Title),
|
|
};
|
|
Dictionary<DataKey<IDocumentMetaData>, IDocumentMetaData> meta = [];
|
|
meta.Add(IArchitecture.Default.ChapterKey, articleData);
|
|
if (metaData is not null)
|
|
meta.Add(IArchitecture.Default.BookKey, metaData);
|
|
return Task.FromResult<IDocument>(new StringDocument(Path.GetRandomFileName(), OnlineCleaner.Clean(resolved?.Content)) {
|
|
MetaData = meta
|
|
});
|
|
};
|
|
}
|
|
}
|