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 foreach (
object Item
in A)
160 this.AppendChild(Document,
Parent, Item);
174 if (CheckAgainst is XmlText ||
175 CheckAgainst is XmlWhitespace ||
176 CheckAgainst is XmlSignificantWhitespace ||
177 CheckAgainst is XmlCDataSection)
181 else if (CheckAgainst is XmlElement)
183 else if (CheckAgainst is
null)
202 return this.node.
PatternMatch(CheckAgainst, AlreadyFound);
211 public override bool IsApplicable(XmlNode CheckAgainst, XmlElement First)
213 if (CheckAgainst is XmlElement E)
220 E.LocalName == First.LocalName &&
221 E.NamespaceURI == First.NamespaceURI;
226 return CheckAgainst is XmlText ||
227 CheckAgainst is XmlWhitespace ||
228 CheckAgainst is XmlSignificantWhitespace ||
229 CheckAgainst is XmlCDataSection;
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 ToExpressionString(object Value)
Converts an object 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 or created.
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.
override bool IsApplicable(XmlNode CheckAgainst, XmlElement First)
If the node is applicable in pattern matching against CheckAgainst .
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 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