public static BuildFilter FromXml(XmlElement xe) { BuildFilter bf = new BuildFilter(); bf.Property = xe.InnerText; bf.Slot = (SlotType)Enum.Parse(typeof(SlotType), xe.GetAttribute("slot")); bf.Type = xe.GetAttribute("type"); if (string.IsNullOrWhiteSpace(bf.Type)) { bf.Type = null; } bf.Include = bool.Parse(xe.GetAttribute("include")); return(bf); }
public static GearSetBuild FromXml(XmlDocument doc, bool filters, bool results) { GearSetBuild build = new GearSetBuild(); try { build.AppVersion = doc.DocumentElement.GetAttribute("version"); build.MinimumLevel = int.Parse(doc.GetElementsByTagName("MinimumLevel")[0].InnerText); build.MaximumLevel = int.Parse(doc.GetElementsByTagName("MaximumLevel")[0].InnerText); if (filters) { XmlElement xe = doc.GetElementsByTagName("Filters")[0] as XmlElement; if (xe != null) { foreach (XmlElement xf in xe.ChildNodes) { BuildFilter bf = BuildFilter.FromXml(xf); build.Filters[bf.Slot].Add(bf); } } } if (results) { XmlElement xe = doc.GetElementsByTagName("BuildResults")[0] as XmlElement; if (xe != null) { foreach (XmlElement xb in xe.ChildNodes) { GearSetEvaluation gse = GearSetEvaluation.FromXml(xb); build.BuildResults.Add(gse); } } } return(build); } catch { return(null); } }