private void GetConfigDefinitionUpdates(bool requireUpdates, ConfigurationSaveMode saveMode, bool forceSaveAll, out ConfigDefinitionUpdates definitionUpdates, out ArrayList configSourceUpdates)
{
definitionUpdates = new ConfigDefinitionUpdates();
configSourceUpdates = null;
bool hasRemovedSections = this.HasRemovedSections;
if (base._sectionRecords != null)
{
base.InitProtectedConfigurationSection();
foreach (DictionaryEntry entry in base._sectionRecords)
{
string key = (string) entry.Key;
SectionRecord sectionRecord = (SectionRecord) entry.Value;
sectionRecord.AddUpdate = false;
bool hasFileInput = sectionRecord.HasFileInput;
OverrideModeSetting locationDefault = OverrideModeSetting.LocationDefault;
bool inheritInChildApps = true;
bool moved = false;
string xmlElement = null;
bool flag5 = false;
if (!sectionRecord.HasResult)
{
if (sectionRecord.HasFileInput)
{
SectionXmlInfo sectionXmlInfo = sectionRecord.FileInput.SectionXmlInfo;
locationDefault = sectionXmlInfo.OverrideModeSetting;
inheritInChildApps = !sectionXmlInfo.SkipInChildApps;
flag5 = requireUpdates && !string.IsNullOrEmpty(sectionXmlInfo.ConfigSource);
}
}
else
{
ConfigurationSection result = (ConfigurationSection) sectionRecord.Result;
if ((base.TargetFramework != null) && !result.ShouldSerializeSectionInTargetVersion(base.TargetFramework))
{
continue;
}
locationDefault = result.SectionInformation.OverrideModeSetting;
inheritInChildApps = result.SectionInformation.InheritInChildApplications;
if (!result.SectionInformation.AllowLocation && (!locationDefault.IsDefaultForLocationTag || !inheritInChildApps))
{
throw new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_inconsistent_location_attributes", new object[] { key }));
}
flag5 = requireUpdates && !string.IsNullOrEmpty(result.SectionInformation.ConfigSource);
try
{
bool flag6 = (result.SectionInformation.ForceSave || result.IsModified()) || (forceSaveAll && !result.SectionInformation.IsLocked);
bool flag7 = this.AreSectionAttributesModified(sectionRecord, result);
bool flag8 = flag6 || (result.SectionInformation.RawXml != null);
if (flag8 || flag7)
{
result.SectionInformation.VerifyIsEditable();
result.SectionInformation.Removed = false;
hasFileInput = true;
moved = this.IsConfigSectionMoved(sectionRecord, result);
if (!flag5)
{
flag5 = !string.IsNullOrEmpty(result.SectionInformation.ConfigSource) && (flag8 || result.SectionInformation.ConfigSourceModified);
}
if ((flag6 || (result.SectionInformation.RawXml == null)) || (saveMode == ConfigurationSaveMode.Full))
{
ConfigurationSection parentElement = this.FindImmediateParentSection(result);
xmlElement = result.SerializeSection(parentElement, result.SectionInformation.Name, saveMode);
this.ValidateSectionXml(xmlElement, key);
}
else
{
xmlElement = result.SectionInformation.RawXml;
}
if (string.IsNullOrEmpty(xmlElement) && ((!string.IsNullOrEmpty(result.SectionInformation.ConfigSource) || !result.SectionInformation.LocationAttributesAreDefault) || (result.SectionInformation.ProtectionProvider != null)))
{
xmlElement = this.WriteEmptyElement(result.SectionInformation.Name);
}
if (string.IsNullOrEmpty(xmlElement))
{
result.SectionInformation.Removed = true;
xmlElement = null;
hasFileInput = false;
if (sectionRecord.HasFileInput)
{
hasRemovedSections = true;
sectionRecord.RemoveFileInput();
}
goto Label_0416;
}
if ((flag7 || moved) || string.IsNullOrEmpty(result.SectionInformation.ConfigSource))
{
hasRemovedSections = true;
}
if (result.SectionInformation.ProtectionProvider == null)
{
goto Label_0416;
}
ProtectedConfigurationSection section = base.GetSection("configProtectedData") as ProtectedConfigurationSection;
try
{
xmlElement = ProtectedConfigurationSection.FormatEncryptedSection(base.Host.EncryptSection(xmlElement, result.SectionInformation.ProtectionProvider, section), result.SectionInformation.Name, result.SectionInformation.ProtectionProvider.Name);
goto Label_0416;
}
catch (Exception exception)
{
throw new ConfigurationErrorsException(System.Configuration.SR.GetString("Encryption_failed", new object[] { result.SectionInformation.SectionName, result.SectionInformation.ProtectionProvider.Name, exception.Message }), exception);
}
}
if (result.SectionInformation.Removed)
{
hasFileInput = false;
if (sectionRecord.HasFileInput)
{
hasRemovedSections = true;
}
}
}
catch (Exception exception2)
{
throw new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_exception_in_config_section_handler", new object[] { result.SectionInformation.SectionName }), exception2);
}
}
Label_0416:
if (hasFileInput)
{
if (base.GetSectionLockedMode(sectionRecord.ConfigKey) == OverrideMode.Deny)
{
throw new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_section_locked"), null);
}
sectionRecord.AddUpdate = true;
DefinitionUpdate update = definitionUpdates.AddUpdate(locationDefault, inheritInChildApps, moved, xmlElement, sectionRecord);
if (flag5)
{
if (configSourceUpdates == null)
{
configSourceUpdates = new ArrayList();
}
configSourceUpdates.Add(update);
}
}
}
}
if (this._flags[0x1000000])
{
hasRemovedSections = true;
definitionUpdates.RequireLocation = true;
}
if (this._flags[0x2000000])
{
hasRemovedSections = true;
}
if (hasRemovedSections)
{
definitionUpdates.CompleteUpdates();
}
else
{
definitionUpdates = null;
}
}