public SpellList() { List <SpellAlias> list = new List <SpellAlias>(64); Settings settings = new SynchronizedSettings("SpellNames"); settings.Path = Path.Combine(Core.Directory, FileName); if (File.Exists(settings.Path)) { settings.Load(); } else { CreateDefault(settings); settings.Save(); } ElementInfo[] elementList = settings.EnumarateElements("Spell"); for (int i = 0; i < elementList.Length; i++) { object aliasObj; object spellObj; if (!elementList[i].Attributes.TryGetValue("alias", out aliasObj)) { continue; } if (!elementList[i].Attributes.TryGetValue("number", out spellObj)) { continue; } string alias = aliasObj.ToString().ToLowerInvariant(); string spellStr = spellObj.ToString(); byte spell; if (spellStr.StartsWith("0x") && Byte.TryParse(spellStr.Remove(0, 2), NumberStyles.HexNumber, null, out spell)) { list.Add(new SpellAlias(alias, spell)); } else if (Byte.TryParse(spellStr, out spell)) { list.Add(new SpellAlias(alias, spell)); } } spellList = list.ToArray(); }
public SynchronizedSettings Load(string name, string rootname) { if (!name.EndsWith(".xml", StringComparison.InvariantCultureIgnoreCase)) { name += ".xml"; } string path = Path.Combine(directory.FullName, name); SynchronizedSettings settings = new SynchronizedSettings(rootname); settings.Path = path; settings.Load(); return(settings); }