//Reads data from Resources/GenericResponses.xml private void CSspReadGenericResponsesData() { genericResponsesDictionary = new Dictionary <int, SspGenericResponse>(); XmlDocument document = new XmlDocument(); SspGenericResponse SspGenericResponse = new SspGenericResponse(); int i = 0; document.Load("Resources/GenericResponses.xml"); XmlNodeList nodeList = document.DocumentElement.SelectNodes("/Root/GenericResponseInfo"); //Loop through all GenericResponseInfo nodes in /Root. foreach (XmlNode node in nodeList) { //The xml document contains a GenericResponseInfo node for every possible (0x00 to 0xFF) value of GenericResponseCode. //Only process nodes witha a <"GenericResponseName"/> child if (node.SelectSingleNode("GenericResponseName") != null) { //Add GenericResponseCode and GenericResponseName into the dictionary. i = Int32.Parse(node.SelectSingleNode("GenericResponseCode").InnerText); SspGenericResponse.ResponseName = node.SelectSingleNode("GenericResponseName").InnerText; genericResponsesDictionary.Add(i, SspGenericResponse); } } }
//Takes responseCode and returns ResponseName from dictionary public string GetGenericResponseName(int responseCode) { SspGenericResponse SspGenRep = new SspGenericResponse(); if (genericResponsesDictionary.ContainsKey(responseCode)) { SspGenRep = genericResponsesDictionary[responseCode]; return(SspGenRep.ResponseName); } return("Unknown Response"); }