Introduce Beam.Fluent and Beam.Models projects
Added new Beam.Fluent and Beam.Models projects with staged download builder and data context models. Refactored and moved model classes from Beam.Temporary.Cli to Beam.Models. Added new data providers and extended DataBindings in Beam.Dynamic. Renamed Beam.Puppeteer to Beam.Playwright and updated related classes. Updated project references and package versions. Removed obsolete and unused files from Beam.Temporary.Cli.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using HtmlAgilityPack;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Beam.Dynamic {
|
||||
public class AnchorDataProvider : IDataProvider<SourceLink>, IDataProvider<string> {
|
||||
public IBinding? Content { get; set; }
|
||||
|
||||
public string Get(HtmlDocument document) {
|
||||
if (Content is null)
|
||||
return "";
|
||||
|
||||
return Content.Select(document)?.GetAttributeValue("href", "") ?? "";
|
||||
|
||||
}
|
||||
|
||||
SourceLink IDataProvider<SourceLink>.Get(HtmlDocument document) {
|
||||
var content = Get(document);
|
||||
if (content is null)
|
||||
return SourceLink.InvalidLink;
|
||||
|
||||
if (!Uri.TryCreate(content, UriKind.RelativeOrAbsolute, out _))
|
||||
return SourceLink.InvalidLink;
|
||||
|
||||
return new SourceLink(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user