ResetModified() private méthode

private ResetModified ( ) : void
Résultat void
Exemple #1
0
 private object CreateSectionImpl(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, object parentConfig, ConfigXmlReader reader)
 {
     if (this._sectionCtor != null)
     {
         ConfigurationSection section = (ConfigurationSection)System.Configuration.TypeUtil.InvokeCtorWithReflectionPermission(this._sectionCtor);
         section.SectionInformation.SetRuntimeConfigurationInformation(configRecord, factoryRecord, sectionRecord);
         section.CallInit();
         ConfigurationSection parentElement = (ConfigurationSection)parentConfig;
         section.Reset(parentElement);
         if (reader != null)
         {
             section.DeserializeSection(reader);
         }
         ConfigurationErrorsException errors = section.GetErrors();
         if (errors != null)
         {
             throw errors;
         }
         section.SetReadOnly();
         section.ResetModified();
         return(section);
     }
     if (reader != null)
     {
         XmlNode xmlNode = ErrorInfoXmlDocument.CreateSectionXmlNode(reader);
         CheckForLockAttributes(factoryRecord.ConfigKey, xmlNode);
         object configContext = configRecord.Host.CreateDeprecatedConfigContext(configRecord.ConfigPath);
         return(this._sectionHandler.Create(parentConfig, configContext, xmlNode));
     }
     return(null);
 }
Exemple #2
0
            internal object CreateSection(bool inputIsTrusted, RuntimeConfigurationRecord configRecord,
                                          FactoryRecord factoryRecord, SectionRecord sectionRecord, object parentConfig, ConfigXmlReader reader)
            {
                object config;

                if (_sectionCtor != null)
                {
                    ConfigurationSection configSection =
                        (ConfigurationSection)_sectionCtor.Invoke(null);

                    configSection.SectionInformation.SetRuntimeConfigurationInformation(configRecord, factoryRecord,
                                                                                        sectionRecord);

                    configSection.CallInit();

                    ConfigurationSection parentSection = (ConfigurationSection)parentConfig;
                    configSection.Reset(parentSection);

                    if (reader != null)
                    {
                        configSection.DeserializeSection(reader);
                    }

                    // throw if there are any cached errors
                    ConfigurationErrorsException errors = configSection.GetErrors();
                    if (errors != null)
                    {
                        throw errors;
                    }

                    // don't allow changes to sections at runtime
                    configSection.SetReadOnly();

                    // reset the modified bit
                    configSection.ResetModified();

                    config = configSection;
                }
                else
                {
                    if (reader != null)
                    {
                        XmlNode xmlNode = ErrorInfoXmlDocument.CreateSectionXmlNode(reader);

                        CheckForLockAttributes(factoryRecord.ConfigKey, xmlNode);

                        // In v1, our old section handler expects a context that contains the virtualPath from the configPath
                        object configContext = configRecord.Host.CreateDeprecatedConfigContext(configRecord.ConfigPath);

                        config = _sectionHandler.Create(parentConfig, configContext, xmlNode);
                    }
                    else
                    {
                        config = null;
                    }
                }

                return(config);
            }
Exemple #3
0
        internal override void ResetModified(Configuration config)
        {
            ConfigurationSection section = config.GetSectionInstance(this, false);

            if (section != null)
            {
                section.ResetModified();
            }
        }
        //
        // Update the section with the XML provided.
        //
        // This method will throw out any changes made to the section up to this point.
        //
        // If xmlElement is null or empty, it is equivalent to calling RevertToParent
        //
        internal void SetRawXml(ConfigurationSection configSection, string xmlElement) {

            // Null or empty is equivalent to RevertToParent().
            if (string.IsNullOrEmpty(xmlElement)) {
                RevertToParent(configSection);
                return;
            }

            ValidateSectionXml(xmlElement, configSection.SectionInformation.Name);

            // Reset the ConfigurationSection with the XML.
            ConfigurationSection parentConfigSection = FindImmediateParentSection(configSection);
            ConfigXmlReader reader = new ConfigXmlReader(xmlElement, null, 0);

            // Store the raw XML.
            configSection.SectionInformation.RawXml = xmlElement;

            // Update the section with the xml
            try {
                try {
                    bool wasPresent = configSection.ElementPresent;
                    PropertySourceInfo saveInfo = configSection.ElementInformation.PropertyInfoInternal();

                    configSection.Reset(parentConfigSection);
                    configSection.DeserializeSection(reader);
                    configSection.ResetModified();

                    configSection.ElementPresent = wasPresent;
                    configSection.ElementInformation.ChangeSourceAndLineNumber(saveInfo);
                }
                catch {
                    configSection.SectionInformation.RawXml = null;
                    throw;
                }
            }
            catch (Exception e) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Config_exception_in_config_section_handler, configSection.SectionInformation.SectionName),
                        e, null, 0);
            }

            // Ignore previous attempts to remove the section.
            configSection.SectionInformation.Removed = false;
        }
        //
        // Revert the ConfigurationSection to the value of its parent.
        //
        internal void RevertToParent(ConfigurationSection configSection) {

            // Remove any RawXml set by ConfigurationSection.SetRawXml
            configSection.SectionInformation.RawXml = null;

            try {
                // Reset to parent value
                ConfigurationSection parentConfigSection = FindImmediateParentSection(configSection);
                configSection.Reset(parentConfigSection);

                // Consider it to be unmodified
                configSection.ResetModified();
            }
            catch (Exception e) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Config_exception_in_config_section_handler, configSection.SectionInformation.SectionName),
                        e, ConfigStreamInfo.StreamName, 0);
            }

            // Record that the section is to be removed.
            configSection.SectionInformation.Removed = true;
        }
 internal void SetRawXml(ConfigurationSection configSection, string xmlElement)
 {
     if (string.IsNullOrEmpty(xmlElement))
     {
         this.RevertToParent(configSection);
     }
     else
     {
         this.ValidateSectionXml(xmlElement, configSection.SectionInformation.Name);
         ConfigurationSection parentElement = this.FindImmediateParentSection(configSection);
         ConfigXmlReader reader = new ConfigXmlReader(xmlElement, null, 0);
         configSection.SectionInformation.RawXml = xmlElement;
         try
         {
             try
             {
                 bool elementPresent = configSection.ElementPresent;
                 PropertySourceInfo sourceInformation = configSection.ElementInformation.PropertyInfoInternal();
                 configSection.Reset(parentElement);
                 configSection.DeserializeSection(reader);
                 configSection.ResetModified();
                 configSection.ElementPresent = elementPresent;
                 configSection.ElementInformation.ChangeSourceAndLineNumber(sourceInformation);
             }
             catch
             {
                 configSection.SectionInformation.RawXml = null;
                 throw;
             }
         }
         catch (Exception exception)
         {
             throw new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_exception_in_config_section_handler", new object[] { configSection.SectionInformation.SectionName }), exception, null, 0);
         }
         configSection.SectionInformation.Removed = false;
     }
 }
 internal void RevertToParent(ConfigurationSection configSection)
 {
     configSection.SectionInformation.RawXml = null;
     try
     {
         ConfigurationSection parentElement = this.FindImmediateParentSection(configSection);
         configSection.Reset(parentElement);
         configSection.ResetModified();
     }
     catch (Exception exception)
     {
         throw new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_exception_in_config_section_handler", new object[] { configSection.SectionInformation.SectionName }), exception, base.ConfigStreamInfo.StreamName, 0);
     }
     configSection.SectionInformation.Removed = true;
 }