Ejemplo n.º 1
0
        private static ServerProfile[] Load()
        {
            if (!File.Exists(Engine.FileManager.BasePath("Data/Profiles.xml")))
            {
                return(new ServerProfile[0]);
            }
            XmlDocument document = new XmlDocument();

            document.Load(Engine.FileManager.BasePath("Data/Profiles.xml"));
            ArrayList list = new ArrayList();

            foreach (XmlElement element in document.GetElementsByTagName("server"))
            {
                string        attribute = element.GetAttribute("title");
                string        address   = element.GetAttribute("address");
                string        s         = element.GetAttribute("port");
                ServerProfile server    = new ServerProfile(attribute, address, XmlConvert.ToInt32(s));
                foreach (XmlElement element2 in element.GetElementsByTagName("account"))
                {
                    string         title    = element2.GetAttribute("title");
                    string         username = element2.GetAttribute("username");
                    string         password = element2.GetAttribute("password");
                    AccountProfile account  = new AccountProfile(server, title, username, password);
                    foreach (XmlElement element3 in element2.GetElementsByTagName("shard"))
                    {
                        string       name     = element3.GetAttribute("name");
                        string       ipString = element3.GetAttribute("address");
                        string       str10    = element3.GetAttribute("port");
                        string       str11    = element3.GetAttribute("index");
                        string       str12    = element3.GetAttribute("timeZone");
                        string       str13    = element3.GetAttribute("percentFull");
                        string       str14    = element3.GetAttribute("auth");
                        ShardProfile shard    = new ShardProfile(account, IPAddress.Parse(ipString), XmlConvert.ToInt32(str10), XmlConvert.ToInt32(str11), XmlConvert.ToInt32(str12), XmlConvert.ToInt32(str13), XmlConvert.ToInt32(str14), name);
                        foreach (XmlElement element4 in element3.GetElementsByTagName("character"))
                        {
                            string str15 = element4.GetAttribute("index");
                            string str16 = element4.GetAttribute("name");
                            shard.AddCharacter(new CharacterProfile(shard, str16, XmlConvert.ToInt32(str15)));
                        }
                        account.AddShard(shard);
                    }
                    server.AddAccount(account);
                }
                list.Add(server);
            }
            return((ServerProfile[])list.ToArray(typeof(ServerProfile)));
        }
Ejemplo n.º 2
0
 private static ServerProfile[] Load()
 {
     if (!File.Exists(Engine.FileManager.BasePath("Data/Profiles.xml")))
     {
         return new ServerProfile[0];
     }
     XmlDocument document = new XmlDocument();
     document.Load(Engine.FileManager.BasePath("Data/Profiles.xml"));
     ArrayList list = new ArrayList();
     foreach (XmlElement element in document.GetElementsByTagName("server"))
     {
         string attribute = element.GetAttribute("title");
         string address = element.GetAttribute("address");
         string s = element.GetAttribute("port");
         ServerProfile server = new ServerProfile(attribute, address, XmlConvert.ToInt32(s));
         foreach (XmlElement element2 in element.GetElementsByTagName("account"))
         {
             string title = element2.GetAttribute("title");
             string username = element2.GetAttribute("username");
             string password = element2.GetAttribute("password");
             AccountProfile account = new AccountProfile(server, title, username, password);
             foreach (XmlElement element3 in element2.GetElementsByTagName("shard"))
             {
                 string name = element3.GetAttribute("name");
                 string ipString = element3.GetAttribute("address");
                 string str10 = element3.GetAttribute("port");
                 string str11 = element3.GetAttribute("index");
                 string str12 = element3.GetAttribute("timeZone");
                 string str13 = element3.GetAttribute("percentFull");
                 string str14 = element3.GetAttribute("auth");
                 ShardProfile shard = new ShardProfile(account, IPAddress.Parse(ipString), XmlConvert.ToInt32(str10), XmlConvert.ToInt32(str11), XmlConvert.ToInt32(str12), XmlConvert.ToInt32(str13), XmlConvert.ToInt32(str14), name);
                 foreach (XmlElement element4 in element3.GetElementsByTagName("character"))
                 {
                     string str15 = element4.GetAttribute("index");
                     string str16 = element4.GetAttribute("name");
                     shard.AddCharacter(new CharacterProfile(shard, str16, XmlConvert.ToInt32(str15)));
                 }
                 account.AddShard(shard);
             }
             server.AddAccount(account);
         }
         list.Add(server);
     }
     return (ServerProfile[]) list.ToArray(typeof(ServerProfile));
 }