Пример #1
0
        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);
            }
        }
Пример #2
0
        public static GearSetEvaluation FromXml(XmlElement xe)
        {
            try
            {
                GearSet    gs  = GearSet.FromXml(xe.GetElementsByTagName("GearSet")[0] as XmlElement);
                XmlElement xls = xe.GetElementsByTagName("LockedSlots")[0] as XmlElement;
                List <EquipmentSlotType> ls = new List <EquipmentSlotType>();
                foreach (XmlElement xc in xls.ChildNodes)
                {
                    ls.Add((EquipmentSlotType)Enum.Parse(typeof(EquipmentSlotType), xc.InnerText));
                }
                GearSetEvaluation gse = new GearSetEvaluation(gs, ls);
                gse.Rating  = int.Parse(xe.GetAttribute("rating"));
                gse.Penalty = int.Parse(xe.GetAttribute("penalty"));

                return(gse);
            }
            catch { return(null); }
        }