32 lines
913 B
C#
32 lines
913 B
C#
using HtmlAgilityPack;
|
|
using System.Text;
|
|
|
|
namespace Beam.Dynamic {
|
|
public class ListContentDataProvider : IDataProvider {
|
|
public Binding? Content { get; set; }
|
|
|
|
public string Get(HtmlDocument document) {
|
|
if (Content is null)
|
|
return "";
|
|
|
|
var node = Content.ResolveNode(document);
|
|
if (node is null)
|
|
return "";
|
|
|
|
StringBuilder content = new();
|
|
foreach(var childNode in node.ChildNodes.SkipLast(1)) {
|
|
if (childNode.Name != "li")
|
|
continue;
|
|
content.Append(childNode.InnerText.Trim() + ";");
|
|
}
|
|
|
|
content.Append(node.ChildNodes.Last().InnerText.Trim());
|
|
return content.ToString();
|
|
}
|
|
|
|
public HtmlNode? GetNode(HtmlDocument document) {
|
|
return Content?.ResolveNode(document);
|
|
}
|
|
}
|
|
}
|