Exemplo n.º 1
0
        private void ChangeRealmlist(RealmlistItem item)
        {
            if (item.Addon < Expansion.MistsOfPandaria)
            {
                string[] realmlistLines = File.ReadAllLines(item.GetRealmlistPath(language_));
                string   firstLine      = "set realmlist " + item.Address;
                realmlistLines[0] = firstLine;
                File.WriteAllLines(item.GetRealmlistPath(language_), realmlistLines);
            }
            else
            {
                string   realmlistLine = "SET realmlist \"" + item.Address + "\"";
                string[] configLines   = File.ReadAllLines(item.GetRealmlistPath(language_));

                bool replaced = false;
                for (int i = 0; i < configLines.Length; i++)
                {
                    if (configLines[i].Contains("SET realmlist"))
                    {
                        configLines[i] = realmlistLine;
                        replaced       = true;
                        break;
                    }
                }

                if (replaced)
                {
                    File.WriteAllLines(item.GetRealmlistPath(language_), configLines);
                }
                else
                {
                    File.AppendAllText(item.GetRealmlistPath(language_), Environment.NewLine + realmlistLine);
                }
            }
        }
Exemplo n.º 2
0
        private void DeleteRealmlistFromConfig(RealmlistItem item)
        {
            if (item.Addon > Expansion.Cataclysm)
            {
                List <string> configLines = File.ReadAllLines(item.GetRealmlistPath(language_)).ToList <String>();

                bool removed = false;
                for (int i = 0; i < configLines.Count; i++)
                {
                    if (configLines[i].Contains("SET realmlist"))
                    {
                        configLines.RemoveAt(i);
                        removed = true;
                    }
                }

                if (removed)
                {
                    File.WriteAllLines(item.GetRealmlistPath(language_), configLines);
                }
            }
        }