Beispiel #1
0
        /// <summary>
        /// Undoes the edit made to the spcified key.
        /// </summary>
        /// <param name="p_strSettingsFileName">The name of the settings file to unedit.</param>
        /// <param name="p_strSection">The section in the Ini file to unedit.</param>
        /// <param name="p_strKey">The key in the Ini file to unedit.</param>
        public void UneditIni(string p_strSettingsFileName, string p_strSection, string p_strKey)
        {
            string strKey             = InstallLog.GetModKey(Mod);
            string strCurrentOwnerKey = InstallLog.GetCurrentIniEditOwnerKey(p_strSettingsFileName, p_strSection, p_strKey);

            //if we didn't edit the value, then leave it alone
            if (!strKey.Equals(strCurrentOwnerKey))
            {
                return;
            }

            if (!TouchedFiles.Contains(p_strSettingsFileName))
            {
                TouchedFiles.Add(p_strSettingsFileName);
                TransactionalFileManager.Snapshot(p_strSettingsFileName);
            }

            //if we did edit the value, replace if with the value we overwrote.
            // if we didn't overwrite a value, then just delete it.
            // writing null effectively deletes the value, so if
            // strPreviousValue is null, indicating we didn't overwrite a value,
            // we still write it
            string strPreviousValue = InstallLog.GetPreviousIniValue(p_strSettingsFileName, p_strSection, p_strKey);

            IniMethods.WritePrivateProfileString(p_strSection, p_strKey, strPreviousValue, p_strSettingsFileName);

            InstallLog.RemoveIniEdit(Mod, p_strSettingsFileName, p_strSection, p_strKey);
        }