當前位置: 首頁>>代碼示例>>C#>>正文


C# ConfigurationSection.DeserializeSection方法代碼示例

本文整理匯總了C#中System.Configuration.ConfigurationSection.DeserializeSection方法的典型用法代碼示例。如果您正苦於以下問題:C# ConfigurationSection.DeserializeSection方法的具體用法?C# ConfigurationSection.DeserializeSection怎麽用?C# ConfigurationSection.DeserializeSection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Configuration.ConfigurationSection的用法示例。


在下文中一共展示了ConfigurationSection.DeserializeSection方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的System.Configuration.ConfigurationSection.DeserializeSection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。