BadScript 2
Loading...
Searching...
No Matches
BadCopyNodeTransformer.cs
Go to the documentation of this file.
1using HtmlAgilityPack;
2
3// ReSharper disable once InvalidXmlDocComment
8
14{
16 protected override bool CanTransform(BadHtmlContext context)
17 {
18 return true;
19 }
20
22 protected override void TransformNode(BadHtmlContext context)
23 {
24 //Clone Node(not children)
25 HtmlNode? node = context.InputNode.CloneNode(false);
26
27 //Append Node to output
28 context.OutputNode.AppendChild(node);
29
30 TransformAttributes(context, node);
31
32 //Iterate through children
33 foreach (HtmlNode? child in context.InputNode.ChildNodes)
34 {
35 BadHtmlContext childContext = context.CreateChild(child, node);
36
37 Transform(childContext);
38 }
39 }
40}
Implements the Html Context for the Transformation Process.
BadHtmlContext CreateChild(HtmlNode inputNode, HtmlNode outputNode, BadExecutionContext? executionContext=null)
Creates a child context with the specified input, output node and optional execution context.
readonly HtmlNode InputNode
The Current Input Node.
readonly HtmlNode OutputNode
The Current Output Node.
Base class of all Node transformers.
static void TransformAttributes(BadHtmlContext context, HtmlNode outputNode)
Transforms all attributes of the input node and writes it to the specified output node.
static void Transform(BadHtmlContext context)
Transforms the input node with one of the registered transformers.
Copies the current node to the output and transforms the attributes This is the default transformer.
override void TransformNode(BadHtmlContext context)
override bool CanTransform(BadHtmlContext context)
Implementations of Html Node Transformers that are used in the Transformation Process.