Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
XmlScriptText.cs
2using System.Xml;
5
7{
12 {
13 private readonly string text;
14 private readonly bool isWhitespace;
15
24 : base(Start, Length, Expression)
25 {
26 this.text = Text;
27 this.isWhitespace = string.IsNullOrWhiteSpace(Text);
28 }
29
33 public string Text => this.text;
34
38 public override bool IsWhitespace => this.isWhitespace;
39
46 internal override void Build(XmlDocument Document, XmlElement Parent, Variables Variables)
47 {
48 Parent.AppendChild(Document.CreateTextNode(this.text));
49 }
50
57 public override PatternMatchResult PatternMatch(XmlNode CheckAgainst, Dictionary<string, IElement> AlreadyFound)
58 {
59 if (CheckAgainst is XmlText ||
60 CheckAgainst is XmlCDataSection ||
61 CheckAgainst is XmlWhitespace ||
62 CheckAgainst is XmlSignificantWhitespace)
63 {
64 return CheckAgainst.InnerText.Trim() == this.text.Trim() ? PatternMatchResult.Match : PatternMatchResult.NoMatch;
65 }
66 else if (CheckAgainst is null)
67 return string.IsNullOrWhiteSpace(this.text) ? PatternMatchResult.Match : PatternMatchResult.NoMatch;
68 else
69 return PatternMatchResult.NoMatch;
70 }
71
78 public override bool IsApplicable(XmlNode CheckAgainst, XmlElement First)
79 {
80 return CheckAgainst is XmlText ||
81 CheckAgainst is XmlCDataSection ||
82 CheckAgainst is XmlWhitespace ||
83 CheckAgainst is XmlSignificantWhitespace;
84 }
85
86 }
87}
Class managing a script expression.
Definition: Expression.cs:41
int Length
Length of expression covered by node.
Definition: ScriptNode.cs:101
ScriptNode Parent
Parent node.
Definition: ScriptNode.cs:126
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
Collection of variables.
Definition: Variables.cs:25
Base class for all XML Script leaf nodes in a parsed script tree.
override bool IsApplicable(XmlNode CheckAgainst, XmlElement First)
If the node is applicable in pattern matching against CheckAgainst .
override bool IsWhitespace
If the node represents whitespace.
XmlScriptText(string Text, int Start, int Length, Expression Expression)
XML Script text node.
string Text
Text represented by node.
override PatternMatchResult PatternMatch(XmlNode CheckAgainst, Dictionary< string, IElement > AlreadyFound)
Performs a pattern match operation.
PatternMatchResult
Status result of a pattern matching operation.
Definition: ScriptNode.cs:17