Beispiel #1
0
        /// <summary>
        /// Changes the XML database file name of all games in a given XML database.
        /// </summary>
        /// <param name="oldDatabaseFilePath">Full path to old database file</param>
        /// <param name="newDatabaseFilePath">Full path to new database file</param>
        private void RenameDatabase(string oldDatabaseFilePath, string newDatabaseFilePath)
        {
            if (oldDatabaseFilePath == null || newDatabaseFilePath == null)
            {
                _logger.Warn("Ignoring null value for path from file watcher.");
                return;
            }
            var databaseOld = Path.GetFileName(oldDatabaseFilePath);
            var databaseNew = Path.GetFileName(newDatabaseFilePath);

            _logger.Info("PinballX database {0} renamed from {1} to {2}.", Name, databaseOld, databaseNew);

            // update properties of concerned games
            Games[databaseOld].ToList().ForEach(g => g.DatabaseFile = databaseNew);

            // update database file list
            _threadManager.MainDispatcher.Invoke(() => {
                DatabaseFiles.Remove(databaseOld);
                DatabaseFiles.Add(databaseNew);
            });

            // rename key
            Games[databaseNew] = Games[databaseOld];
            Games.Remove(databaseOld);
        }
Beispiel #2
0
        /// <summary>
        /// Removes all games of a given XML database file.
        /// </summary>
        ///
        /// <remarks>
        /// This means that the database file was deleted.
        /// </remarks>
        ///
        /// <param name="databaseFilePath">Full path to database file</param>
        private void RemoveGames(string databaseFilePath)
        {
            if (databaseFilePath == null)
            {
                _logger.Warn("Ignoring null value for path from file watcher.");
                return;
            }
            var databaseFile = Path.GetFileName(databaseFilePath);

            // update database files
            _threadManager.MainDispatcher.Invoke(() => DatabaseFiles.Remove(databaseFile));

            _gamesUpdated.OnNext(new Tuple <string, List <PinballXGame> >(databaseFile, new List <PinballXGame>()));
        }