コード例 #1
0
        /// <summary>
        /// Attempts to save all modified player files
        /// </summary>
        /// <param name="playerOnError"></param>
        /// <returns>True if there were any modified player files.</returns>
        /// <exception cref="IOException">can happen during file save</exception>
        public bool SaveAllModifiedPlayers(ref PlayerCollection playerOnError)
        {
            int numModified = 0;

            // Save each player as necessary
            foreach (KeyValuePair <string, Lazy <PlayerCollection> > kvp in this.userContext.Players)
            {
                string           playerFile = kvp.Key;
                PlayerCollection player     = kvp.Value.Value;

                if (player == null)
                {
                    continue;
                }

                if (player.IsModified)
                {
                    ++numModified;
                    playerOnError = player;                    // if needed by caller
                    GamePathResolver.BackupFile(player.PlayerName, playerFile);
                    GamePathResolver.BackupStupidPlayerBackupFolder(playerFile);
                    PlayerCollectionProvider.Save(player, playerFile);
                }
            }

            return(numModified > 0);
        }
コード例 #2
0
        /// <summary>
        /// Attempts to save all modified vault files
        /// </summary>
        /// <param name="vaultOnError"></param>
        /// <exception cref="IOException">can happen during file save</exception>
        public void SaveAllModifiedVaults(ref PlayerCollection vaultOnError)
        {
            foreach (KeyValuePair <string, Lazy <PlayerCollection> > kvp in this.userContext.Vaults)
            {
                string           vaultFile = kvp.Key;
                PlayerCollection vault     = kvp.Value.Value;

                if (vault == null)
                {
                    continue;
                }

                if (vault.IsModified)
                {
                    // backup the file
                    vaultOnError = vault;
                    GamePathResolver.BackupFile(vault.PlayerName, vaultFile);
                    PlayerCollectionProvider.Save(vault, vaultFile);
                }
            }
        }
コード例 #3
0
ファイル: StashService.cs プロジェクト: s0da72/TQVaultAE
        /// <summary>
        /// Attempts to save all modified stash files.
        /// </summary>
        /// <param name="stashOnError"></param>
        /// <exception cref="IOException">can happen during file save</exception>
        public void SaveAllModifiedStashes(ref Stash stashOnError)
        {
            // Save each stash as necessary
            foreach (KeyValuePair <string, Lazy <Stash> > kvp in this.userContext.Stashes)
            {
                string stashFile = kvp.Key;
                Stash  stash     = kvp.Value.Value;

                if (stash == null)
                {
                    continue;
                }

                if (stash.IsModified)
                {
                    stashOnError = stash;
                    GamePathResolver.BackupFile(stash.PlayerName, stashFile);
                    StashProvider.Save(stash, stashFile);
                }
            }
        }