Exemple #1
0
        private void RecountGames()
        {
            var serverGames = ServerGames.ToArray();

            for (var i = 0; i < serverGames.Length; i++)
            {
                var item = serverGames[i];
                var game = ServerGamesCache.FirstOrDefault(sg => sg.GameID == item.GameID);
                if (game == null || !FilterGame(game))
                {
                    ServerGames.Remove(item);
                }
            }

            serverGames = ServerGames.ToArray();
            for (var i = 0; i < serverGames.Length; i++)
            {
                var item = serverGames[i];
                var game = ServerGamesCache.FirstOrDefault(sg => sg.GameID == item.GameID);
                if (game != null && game != item)
                {
                    ServerGames[i] = game;
                }
            }

            for (int i = 0; i < ServerGamesCache.Count; i++)
            {
                var item = ServerGamesCache[i];

                var game = ServerGames.FirstOrDefault(sg => sg.GameID == item.GameID);
                if (game == null && FilterGame(item))
                {
                    InsertGame(item);
                }
            }

            if (CurrentGame != null && !ServerGames.Contains(CurrentGame))
            {
                CurrentGame = null;
            }

            if (CurrentGame == null && ServerGames.Any())
            {
                CurrentGame = ServerGames[0];
            }
        }