System.Configuration.ClientSettingsStore.RevertToParent C# (CSharp) Метод

RevertToParent() приватный Метод

private RevertToParent ( string sectionName, bool isRoaming ) : void
sectionName string
isRoaming bool
Результат void
        internal void RevertToParent(string sectionName, bool isRoaming) {
            if (!ConfigurationManagerInternalFactory.Instance.SupportsUserConfig) {
                throw new ConfigurationErrorsException(SR.GetString(SR.UserSettingsNotSupported));
            }

            Configuration config = GetUserConfig(isRoaming);
            ClientSettingsSection section = GetConfigSection(config, sectionName, false);

            // If the section is null, there is nothing to revert.
            if (section != null) {
                section.SectionInformation.RevertToParent();
                config.Save();
            }
        }

Usage Example

Пример #1
0
        /// <summary>
        ///     Implementation of IClientSettingsProvider.Reset. Resets user scoped settings to the values
        ///     in app.exe.config, does nothing for app scoped settings.
        /// </summary>
        public void Reset(SettingsContext context)
        {
            string sectionName = GetSectionName(context);

            // First revert roaming, then local
            ClientSettingsStore.RevertToParent(sectionName, true);
            ClientSettingsStore.RevertToParent(sectionName, false);
        }