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