private static List <Awake> ReadAwakeTypes(XmlNode settingsNode) { var awakeTypeNodes = XmlUtils.GetNode("AwakeTypes", settingsNode.ChildNodes); List <Awake> awakeTypes = new List <Awake>(); foreach (XmlNode awakeTypeNode in awakeTypeNodes) { if (awakeTypeNode.Name == "Type") { var comparisonAttr = XmlUtils.GetAttribute(awakeTypeNode, "comparisonmethod"); AwakeComparisonMethod comparisonMethod = AwakeComparisonMethod.Exact; string substringToFind = ""; if (comparisonAttr != null) { if (comparisonAttr.Value == "Exact") { comparisonMethod = AwakeComparisonMethod.Exact; } else if (comparisonAttr.Value == "Contains") { comparisonMethod = AwakeComparisonMethod.Contains; var textToFindAttr = XmlUtils.GetAttribute(awakeTypeNode, "text_to_find"); if (textToFindAttr == null) { throw new Exception("You are missing the text_to_find attribute in the awake because you have the Contains comparison method."); } substringToFind = textToFindAttr.Value; } else { throw new Exception("No valid awake comparison method"); } } var awake = new Awake() { Name = XmlUtils.GetAttribute(awakeTypeNode, "name").Value, Text = XmlUtils.GetAttribute(awakeTypeNode, "gametext").Value, SubstringToFind = substringToFind, TypeIndex = (short)awakeTypes.Count, ComparisonMethod = comparisonMethod, }; awakeTypes.Add(awake); } } return(awakeTypes); }
private static List <Awake> ReadAwakeTypes(XmlNode settingsNode) { var awakeTypeNodes = XmlUtils.GetNode("AwakeTypes", settingsNode.ChildNodes); List <Awake> awakeTypes = new List <Awake>(); foreach (XmlNode awakeTypeNode in awakeTypeNodes) { if (awakeTypeNode.Name == "Type") { var comparisonAttr = XmlUtils.GetAttribute(awakeTypeNode, "comparisonmethod"); AwakeComparisonMethod comparisonMethod = AwakeComparisonMethod.Exact; if (comparisonAttr != null) { if (comparisonAttr.Value == "Exact") { comparisonMethod = AwakeComparisonMethod.Exact; } else if (comparisonAttr.Value == "Contains") { comparisonMethod = AwakeComparisonMethod.Contains; } else { throw new Exception("No valid awake comparison method"); } } var awake = new Awake() { Name = XmlUtils.GetAttribute(awakeTypeNode, "name").Value, Text = XmlUtils.GetAttribute(awakeTypeNode, "gametext").Value, TypeIndex = (short)awakeTypes.Count, ComparisonMethod = comparisonMethod, }; awakeTypes.Add(awake); } } return(awakeTypes); }