refactor: unify binding & data provider interfaces

- Removed BindingType enum and all related logic from Binding.
- Made Binding implement new IBinding and IKeyed interfaces.
- Moved node selection logic to IBinding.Select; removed Resolve* methods from Binding.
- Added new IBinding interface for XPath/CssPath selection.
- Refactored IDataProvider to generic IDataProvider<T>; removed GetNode.
- Updated ListContentDataProvider and ParagraphedContentDataProvider to use IBinding.
- Added new ContentsDataProvider, ContentsArrayDataProvider, and DropDownDataProvider for flexible data extraction.
- Updated DataBindings to use IDataProvider<T> properties instead of Binding.
- Updated all usages to new interfaces and patterns.
This commit is contained in:
qwsdcvghyu89
2025-06-30 23:31:39 +03:00
parent 87360d75ab
commit 849bdcd089
18 changed files with 448 additions and 129 deletions
+12 -12
View File
@@ -2,21 +2,21 @@
namespace Beam.Dynamic {
public record class DataBindings {
public Binding? Title { get; set; }
public Binding? Authors { get; set; }
public Binding? Description { get; set; }
public Binding? Content { get; set; }
public Binding? Language { get; set; }
public Binding? Tags { get; set; }
public IDataProvider<string>? Title { get; set; }
public IDataProvider<string[]>? Authors { get; set; }
public IDataProvider<string>? Description { get; set; }
public IDataProvider<string>? Content { get; set; }
public IDataProvider<string[]>? Language { get; set; }
public IDataProvider<string[]>? Tags { get; set; }
public virtual ResolvedBindings Resolve(HtmlDocument doc) {
return new ResolvedBindings() {
Title = Title?.Resolve(doc),
Authors = Authors?.Resolve(doc) ?? Array.Empty<string>(),
Language = Language?.Resolve(doc) ?? Array.Empty<string>(),
Content = Content?.Resolve(doc),
Description = Description?.Resolve(doc),
Tags = Tags?.Resolve(doc) ?? Array.Empty<string>()
Title = Title?.Get(doc),
Authors = Authors?.Get(doc) ?? [],
Language = Language?.Get(doc),
Content = Content?.Get(doc),
Description = Description?.Get(doc),
Tags = Tags?.Get(doc) ?? []
};
}
}