ExecutionNode.cs 850 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.Collections.Generic;
  2. using System.Diagnostics;
  3. using System.Linq;
  4. using System.Xml;
  5. namespace NTERA.Interpreter.Compiler
  6. {
  7. [DebuggerDisplay("{Type}")]
  8. public class ExecutionNode
  9. {
  10. public string Type { get; set; }
  11. public Dictionary<string, string> Metadata { get; set; } = new Dictionary<string, string>();
  12. public string Anchor { get; set; }
  13. public Marker Symbol { get; set; }
  14. public ExecutionNode[] SubNodes { get; set; } = new ExecutionNode[0];
  15. public ExecutionNode this[string type]
  16. {
  17. get { return SubNodes.First(x => x.Type == type); }
  18. }
  19. public void WriteXml(XmlWriter writer)
  20. {
  21. writer.WriteStartElement(Type);
  22. foreach (var kv in Metadata)
  23. writer.WriteAttributeString(kv.Key, kv.Value);
  24. foreach (var node in SubNodes)
  25. node.WriteXml(writer);
  26. writer.WriteEndElement();
  27. }
  28. }
  29. }