From b95e8d42eb7df67cd6e60dd6e47d3a565a5c7755 Mon Sep 17 00:00:00 2001 From: GittyMac Date: Tue, 19 Jul 2022 22:17:30 -0400 Subject: [PATCH] Update A1_Parser with descendant parsing. --- A1Emu/A1_Utils/A1_Parser.cs | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/A1Emu/A1_Utils/A1_Parser.cs b/A1Emu/A1_Utils/A1_Parser.cs index 3e83422..4f2e441 100644 --- a/A1Emu/A1_Utils/A1_Parser.cs +++ b/A1Emu/A1_Utils/A1_Parser.cs @@ -53,6 +53,19 @@ public class A1_Parser commandInfo.Add(value); } + //Allows parsing of descendant elements. + foreach(XElement element in commandRoot.Descendants()){ + var desAttrNames = ( + from a in element.Attributes() + select a.Value + ); + + foreach (string value in desAttrNames) + { + commandInfo.Add(value); + } + } + if (routingString != "") { string[] routingData = routingString.Split("|"); @@ -65,4 +78,29 @@ public class A1_Parser return commandInfo.ToArray(); } + //Gets the Routing String from the command. + public string[] ParseRoutingStrings(string command) + { + + List routeInfo = new List(); + string routingString = ""; + + if (command.EndsWith("#")) + { + routingString = command.Substring(command.LastIndexOf(">") + 1, command.LastIndexOf("#") - command.LastIndexOf(">") - 1); + command = command.Substring(0, command.LastIndexOf(">") + 1); + } + + if (routingString != "") + { + string[] routingData = routingString.Split("|"); + foreach (string routeID in routingData) + { + routeInfo.Add(routeID); + } + } + + return routeInfo.ToArray(); + } + } \ No newline at end of file