当前位置: 首页>>代码示例>>C#>>正文


C# ConfigurationSection.Reset方法代码示例

本文整理汇总了C#中System.Configuration.ConfigurationSection.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigurationSection.Reset方法的具体用法?C# ConfigurationSection.Reset怎么用?C# ConfigurationSection.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Configuration.ConfigurationSection的用法示例。


在下文中一共展示了ConfigurationSection.Reset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetRawXml

        //
        // 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;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:50,代码来源:MgmtConfigurationRecord.cs

示例2: SetRawXml

 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;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:37,代码来源:MgmtConfigurationRecord.cs

示例3: RevertToParent

        //
        // 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;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:24,代码来源:MgmtConfigurationRecord.cs

示例4: RevertToParent

 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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:MgmtConfigurationRecord.cs


注:本文中的System.Configuration.ConfigurationSection.Reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。