Beispiel #1
0
 private void ImportProfileServersIfNeeded()
 {
     try
     {
         if (!Properties.Settings.Default.HaveImportedProfileServers)
         {
             var persister  = new GameManagement.ServerPersister(ServerManager.GetServerDataFolder());
             var allServers = persister.GetWildWestServerList();
             foreach (var serverName in GetAllProfileServerNames())
             {
                 var existingServer = ServerManager.ServerList.FirstOrDefault(qq => streqi(qq.ServerName, serverName));
                 if (existingServer == null)
                 {
                     var servData = allServers.FirstOrDefault(qq => streqi(qq.ServerName, serverName));
                     if (servData != null)
                     {
                         var model = ServerModel.Create(servData);
                         ServerManager.ServerList.Add(model);
                     }
                     else
                     {
                         Logger.WriteInfo($"Ignoring unknown server '{serverName}'");
                     }
                 }
             }
             Properties.Settings.Default.HaveImportedProfileServers = true;
             Properties.Settings.Default.Save();
         }
     }
     catch (Exception exc)
     {
         Logger.WriteError("Failed to import profile servers: " + exc.ToString());
     }
 }
        private void LoadServers()
        {
            _serverModels.Clear();
            var persister = new GameManagement.ServerPersister(ServerManager.GetServerDataFolder());

            var allServers       = persister.GetWildWestServerList();
            var availableServers = allServers.Where(q => !IsInOurServers(q));

            foreach (var servdata in availableServers)
            {
                ServerModel model = ServerModel.Create(servdata);
                _serverModels.Add(model);
            }
        }