Add project files.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using HtmlAgilityPack;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Beam.Dynamic {
|
||||
public class ParagraphedContentDataProvider : 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) {
|
||||
if (childNode.Name != "p")
|
||||
continue;
|
||||
content.AppendLine(childNode.InnerText);
|
||||
}
|
||||
|
||||
return content.ToString();
|
||||
}
|
||||
|
||||
public HtmlNode? GetNode(HtmlDocument document) {
|
||||
return Content?.ResolveNode(document);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user