849bdcd089
- 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.
25 lines
697 B
C#
25 lines
697 B
C#
using HtmlAgilityPack;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection.Metadata;
|
|
using System.Text;
|
|
using System.Text.Json.Serialization;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Beam.Dynamic {
|
|
[JsonDerivedType(typeof(Binding), "binding")]
|
|
public interface IBinding {
|
|
string? XPath { get; set; }
|
|
string? CssPath { get; set; }
|
|
|
|
HtmlNode? Select(HtmlDocument doc) {
|
|
if (XPath is not null)
|
|
return doc.DocumentNode.SelectSingleNode(XPath);
|
|
if (CssPath is not null)
|
|
return doc.DocumentNode.ThenByClasses(CssPath.Split('/'));
|
|
return null;
|
|
}
|
|
}
|
|
}
|