1using System.Collections.Generic;
2using System.Threading.Tasks;
17 private readonly
int nrInstructions;
35 this.processingInstructions = ProcessingInstructions;
36 this.processingInstructions?.
SetParent(
this);
38 this.nrInstructions = ProcessingInstructions.
Length;
43 private void CalcIsAsync()
49 for (
int i = 0; i < this.nrInstructions; i++)
80 int i, c = this.processingInstructions.Length;
84 for (i = 0; i < c; i++)
86 if (!this.processingInstructions[i].
ForAllChildNodes(Callback, State, Order))
95 bool RecalcIsAsync =
false;
98 for (i = 0; i < this.nrInstructions; i++)
100 b = !Callback(this.processingInstructions[i], out NewNode, State);
103 this.processingInstructions[i] = Instruction;
104 Instruction.SetParent(
this);
106 RecalcIsAsync =
true;
109 if (b || (Order ==
SearchMethod.TreeOrder && !
this.processingInstructions[i].ForAllChildNodes(Callback, State, Order)))
118 if (!(this.root is
null))
120 b = !Callback(this.root, out NewNode, State);
126 RecalcIsAsync =
true;
129 if (b || (Order ==
SearchMethod.TreeOrder && !
this.root.ForAllChildNodes(Callback, State, Order)))
140 for (i = 0; i < c; i++)
142 if (!this.processingInstructions[i].
ForAllChildNodes(Callback, State, Order))
160 XmlDocument Doc =
new XmlDocument()
162 PreserveWhitespace =
true
180 XmlDocument Doc =
new XmlDocument()
182 PreserveWhitespace =
true
185 await this.BuildAsync(Doc,
null,
Variables);
212 foreach (XmlScriptProcessingInstruction PI
in this.processingInstructions)
215 if (!(this.root is
null))
227 if (!(CheckAgainst?.AssociatedObjectValue is XmlNode Node))
241 System.Collections.IEnumerable Nodes;
243 if (CheckAgainst is XmlDocument Doc)
244 Nodes = Doc.ChildNodes;
245 else if (CheckAgainst is XmlElement E)
246 Nodes =
new XmlElement[] { E };
251 bool RootMatched =
false;
254 foreach (XmlNode N
in Nodes)
258 if (RootMatched || this.root is
null)
266 else if (N is XmlDeclaration)
268 if (PiIndex < this.processingInstructions.Length &&
269 (Result =
this.processingInstructions[PiIndex++].PatternMatch(N, AlreadyFound)) !=
PatternMatchResult.Match)
274 else if (N is XmlProcessingInstruction)
276 if (PiIndex >= this.processingInstructions.Length)
281 else if (N is XmlComment || N is XmlSignificantWhitespace || N is XmlWhitespace)
287 if (!RootMatched && !(this.root is
null))
290 if (PiIndex < this.processingInstructions.Length)
303 return (CheckAgainst is XmlDocument);
Class managing a script expression.
Base class for all nodes in a parsed script tree.
int Length
Length of expression covered by node.
ScriptNode Parent
Parent node.
int Start
Start position in script expression.
void SetParent(ScriptNode Parent)
Sets the parent node. Can only be used when expression is being parsed.
Represents an script-based XML document.
override async Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
XmlScriptElement Root
Root element.
XmlScriptDocument(XmlScriptElement Root, XmlScriptProcessingInstruction[] ProcessingInstructions, int Start, int Length, Expression Expression)
Represents an script-based XML document.
override bool IsApplicable(XmlNode CheckAgainst)
If the node is applicable in pattern matching against CheckAgainst .
override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, SearchMethod Order)
Calls the callback method for all child nodes.
override IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
override PatternMatchResult PatternMatch(IElement CheckAgainst, Dictionary< string, IElement > AlreadyFound)
Performs a pattern match operation.
override PatternMatchResult PatternMatch(XmlNode CheckAgainst, Dictionary< string, IElement > AlreadyFound)
Performs a pattern match operation.
override bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
override bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
override PatternMatchResult PatternMatch(XmlNode CheckAgainst, Dictionary< string, IElement > AlreadyFound)
Performs a pattern match operation.
override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, SearchMethod Order)
Calls the callback method for all child nodes.
Base class for all XML Script nodes in a parsed script tree.
XML Script processing instruction node.
Basic interface for all types of elements.
delegate bool ScriptNodeEventHandler(ScriptNode Node, out ScriptNode NewNode, object State)
Delegate for ScriptNode callback methods.
PatternMatchResult
Status result of a pattern matching operation.
SearchMethod
Method to traverse the expression structure