void Merge(CodeBlockNested codeBlock, CodeBlockNested mergeBlock) { foreach (CodeBlock mergeBlockChild in mergeBlock.Children) { switch (mergeBlockChild) { case CodeBlockText mergeBlockChildText: // if the name starts with '!', then dont merge child // text blocks. Throw away merge text. if (mergeBlock.Name.StartsWith("!") == false) { foreach (String line in mergeBlockChild.AllLines()) { codeBlock.AppendLine(line, ""); } } break; case CodeBlockNested mergeBlockChildNested: CodeBlockNested codeBlockChildNested = codeBlock.Find(mergeBlockChildNested.Name); if (codeBlockChildNested == null) { codeBlockChildNested = codeBlock.AppendBlock(mergeBlockChildNested.Name); codeBlockChildNested.Load(mergeBlockChildNested.Lines(), false); } else { this.Merge(codeBlockChildNested, mergeBlockChildNested); } break; } } }