Files
Beam/Beam.Dynamic/DataBindings.cs
T
qwsdcvghyu89 849bdcd089 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.
2025-06-30 23:31:39 +03:00

33 lines
1.2 KiB
C#

using HtmlAgilityPack;
namespace Beam.Dynamic {
public record class DataBindings {
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?.Get(doc),
Authors = Authors?.Get(doc) ?? [],
Language = Language?.Get(doc),
Content = Content?.Get(doc),
Description = Description?.Get(doc),
Tags = Tags?.Get(doc) ?? []
};
}
}
public record class ResolvedBindings {
public string? Title { get; set; }
public string[]? Authors { get; set; }
public string? Description { get; set; }
public string? Content { get; set; }
public string[]? Language { get; set; }
public string[]? Tags { get; set; }
}
}