2using System.Collections;
3using System.Collections.Generic;
5using System.Threading.Tasks;
63 bool b = !Callback(this.node, out
ScriptNode NewNode, State);
64 if (!(NewNode is
null))
69 this.isAsync = NewNode.IsAsynchronous;
105 Variables[ParentNamespaceVariableName] = Bak;
109 internal const string ParentNamespaceVariableName =
" Parent NS ";
132 Variables[ParentNamespaceVariableName] = Bak;
136 private void AppendChild(XmlDocument Document, XmlElement
Parent,
object Value)
141 if (Value is
string s)
142 Parent.AppendChild(Document.CreateTextNode(s));
143 else if (Value is
bool b)
145 else if (Value is
double d)
147 else if (Value is DateTime TP)
148 Parent.AppendChild(Document.CreateTextNode(
XML.
Encode(TP, TP.TimeOfDay == TimeSpan.Zero)));
150 Parent.AppendChild(Document.CreateTextNode(cis.Value));
151 else if (Value is BigInteger I)
152 Parent.AppendChild(Document.CreateTextNode(I.ToString()));
153 else if (Value is XmlDocument Doc)
154 Parent.AppendChild(Document.ImportNode(Doc.DocumentElement,
true));
155 else if (Value is XmlElement E)
156 Parent.AppendChild(Document.ImportNode(E,
true));
157 else if (Value is IEnumerable A)
159 IEnumerator e = A.GetEnumerator();
162 this.AppendChild(Document,
Parent, e.Current);
176 if (CheckAgainst is XmlText ||
177 CheckAgainst is XmlWhitespace ||
178 CheckAgainst is XmlSignificantWhitespace ||
179 CheckAgainst is XmlCDataSection)
183 else if (CheckAgainst is XmlElement)
185 else if (CheckAgainst is
null)
204 return this.node.
PatternMatch(CheckAgainst, AlreadyFound);
214 return (CheckAgainst is XmlText ||
215 CheckAgainst is XmlWhitespace ||
216 CheckAgainst is XmlSignificantWhitespace ||
217 CheckAgainst is XmlCDataSection ||
218 CheckAgainst is XmlElement);
Helps with parsing of commong data types.
static string Encode(bool x)
Encodes a Boolean for use in XML and other formats.
Helps with common XML-related tasks.
static string Encode(string s)
Encodes a string for use in XML.
Represents a case-insensitive string.
Base class for all types of elements.
abstract object AssociatedObjectValue
Associated object value.
Class managing a script expression.
static string ToString(double Value)
Converts a value to a string, that can be parsed as part of an expression.
Base class for all nodes in a parsed script tree.
bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
Calls the callback method for all child nodes.
int Length
Length of expression covered by node.
virtual PatternMatchResult PatternMatch(IElement CheckAgainst, Dictionary< string, IElement > AlreadyFound)
Performs a pattern match operation.
ScriptNode Parent
Parent node.
int Start
Start position in script expression.
virtual bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
void SetParent(ScriptNode Parent)
Sets the parent node. Can only be used when expression is being parsed.
abstract IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection. This method should be ...
virtual Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection. This method should be ...
static readonly ObjectValue Null
Null value.
Contains information about a variable.
virtual bool TryGetVariable(string Name, out Variable Variable)
Tries to get a variable object, given its name.
virtual bool Remove(string VariableName)
Removes a varaiable from the collection.
Base class for all XML Script nodes in a parsed script tree.
override PatternMatchResult PatternMatch(XmlNode CheckAgainst, Dictionary< string, IElement > AlreadyFound)
Performs a pattern match operation.
override PatternMatchResult PatternMatch(IElement CheckAgainst, Dictionary< string, IElement > AlreadyFound)
Performs a pattern match operation.
XmlScriptValue(ScriptNode Node, int Start, int Length, Expression Expression)
XML Script value node.
override bool IsVector
If the node represents a vector of nodes.
override bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
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.
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