// Recursively write new sections for each section group.
private bool WriteNewConfigDefinitionsRecursive(XmlUtilWriter utilWriter, SectionUpdates sectionUpdates, int linePosition, int indent, bool skipFirstIndent) {
bool wroteASection = false;
string[] movedSectionNames = sectionUpdates.GetMovedSectionNames();
if (movedSectionNames != null) {
wroteASection = true;
foreach (string configKey in movedSectionNames) {
DefinitionUpdate update = sectionUpdates.GetDefinitionUpdate(configKey);
WriteSectionUpdate(utilWriter, update, linePosition, indent, skipFirstIndent);
utilWriter.AppendNewLine();
skipFirstIndent = false;
}
}
string[] newGroupNames = sectionUpdates.GetNewGroupNames();
if (newGroupNames != null) {
foreach (string group in newGroupNames) {
if (TargetFramework != null) {
ConfigurationSectionGroup g = GetSectionGroup(group);
if (g != null && !g.ShouldSerializeSectionGroupInTargetVersion(TargetFramework)){
sectionUpdates.MarkGroupAsRetrieved(group);
continue;
}
}
if (!skipFirstIndent) {
utilWriter.AppendSpacesToLinePosition(linePosition);
}
skipFirstIndent = false;
utilWriter.Write("<" + group + ">\r\n");
bool recurseWroteASection = WriteNewConfigDefinitionsRecursive(
utilWriter, sectionUpdates.GetSectionUpdatesForGroup(group), linePosition + indent, indent, false);
if (recurseWroteASection) {
wroteASection = true;
}
utilWriter.AppendSpacesToLinePosition(linePosition);
utilWriter.Write("</" + group + ">\r\n");
}
}
sectionUpdates.IsNew = false;
return wroteASection;
}