/// <summary> /// Add a raid template. /// </summary> public void AddTemplate(RaidTemplate temp) { if (temp == null || temp.Name == null || temp.Zone == null || temp.Mobs == null) { throw new ArgumentNullException(); } if (temp.Mobs.Length == 0) { temp.Mobs = new[] { temp.Name } } ; Templates.Add(temp); }
/// <summary> /// Add raid templates from an XML file. /// </summary> public void AddTemplateFromFile(Stream stream) { var xml = XElement.Load(stream, LoadOptions.None); var items = xml.Elements(); foreach (var item in items) { var temp = new RaidTemplate() { Zone = item.Element("Zone")?.Value, Name = item.Element("Name")?.Value, Mobs = item.Elements("Mob").Select(x => x.Value).ToArray(), EndsOnDeath = item.Elements("Mob").Where(x => x.Attribute("EndsOnDeath")?.Value == "true").Select(x => x.Value).ToArray(), //EndsOnDeath = item.Elements("EndsOnDeath").Select(x => x.Value).ToArray(), }; if (!String.IsNullOrEmpty(temp.Zone) && !String.IsNullOrEmpty(temp.Name)) { AddTemplate(temp); } } }