private static XmlElement ConvertBlacklistSet(BlacklistSetting blacklist) { XmlElement element = doc.CreateElement("blacklist"); element.SetAttribute("used", ConfigConvert.ConvertToString(blacklist.Used)); element.SetAttribute("violateTimes", blacklist.ViolateTimes.ToString()); element.SetAttribute("limitDays", blacklist.LimitDays.ToString()); element.SetAttribute("leaveBlacklist", ((int)blacklist.LeaveBlacklist).ToString()); element.SetAttribute("ViolateFailDays", blacklist.ViolateFailDays.ToString()); foreach (ViolationRecordsType violateType in blacklist.ViolateRoule.Keys) { XmlElement child = doc.CreateElement("violateType"); child.SetAttribute("used", ConfigConvert.ConvertToString(blacklist.ViolateRoule[violateType])); child.SetAttribute("typeValue", ((int)violateType).ToString()); element.AppendChild(child); } return(element); }
private static BlacklistSetting ConvertBlacklistSet(XmlNode node) { //node = doc.SelectSingleNode("//blacklist"); BlacklistSetting set = new BlacklistSetting(); set.LeaveBlacklist = (LeaveBlacklistMode)int.Parse(node.Attributes["leaveBlacklist"].Value); set.LimitDays = int.Parse(node.Attributes["limitDays"].Value); set.Used = ConfigConvert.ConvertToBool(node.Attributes["used"].Value); set.ViolateTimes = int.Parse(node.Attributes["violateTimes"].Value); set.ViolateFailDays = int.Parse(node.Attributes["ViolateFailDays"].Value); XmlNodeList nodes = node.ChildNodes;// SelectNodes("//blacklist/violateType"); foreach (XmlNode element in nodes) { set.ViolateRoule[(ViolationRecordsType)int.Parse(element.Attributes["typeValue"].Value)] = ConfigConvert.ConvertToBool(element.Attributes["used"].Value); } return(set); }