Update A1_Parser with descendant parsing.

This commit is contained in:
GittyMac
2022-07-19 22:17:30 -04:00
parent be3ad79660
commit b95e8d42eb

View File

@@ -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<string> routeInfo = new List<string>();
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();
}
}