private void AppendSection(Reporter.Section section) { _msgbuilder.Append($"Start Section: {section.Name}{Environment.NewLine}"); _msgbuilder.AppendLine(); foreach (var child in section.Children) { switch (child) { case Reporter.Exception exception: AppendException(exception); break; case Reporter.Expression expression: AppendExpression(expression); break; case Reporter.Failure failure: AppendFailure(failure); break; case Reporter.FatalErrorCondition fatal: AppendFatalErrorCondition(fatal); break; case Reporter.Info info: AppendInfo(info.Message); break; case Reporter.Section innersection: if (innersection.HasFailuresOrWarnings) { AppendSection(innersection); } break; case Reporter.Warning warning: AppendWarning(warning); break; default: break; } } _msgbuilder.Append($"End Section: {section.Name}{Environment.NewLine}"); _msgbuilder.AppendLine(); }
private void AppendSection(Reporter.Section section, string startstring, string endstring, int level) { if (level == 0) { startstring = $"================================================================================{Environment.NewLine}{section.Name}{Environment.NewLine}"; endstring = $"{section.Name}{Environment.NewLine}================================================================================{Environment.NewLine}"; } else { startstring = $"{startstring}{new string(' ', level*2)}{section.Name}{Environment.NewLine}"; endstring = $"{new string(' ', level * 2)}{section.Name}{Environment.NewLine}{endstring}"; } bool appendstart = true; foreach (var child in section.Children) { switch (child) { case Reporter.Exception exception: if (appendstart) { AppendSectionStart(startstring); appendstart = false; } AppendException(exception); break; case Reporter.Expression expression: if (appendstart) { AppendSectionStart(startstring); appendstart = false; } AppendExpression(expression); break; case Reporter.Failure failure: if (appendstart) { AppendSectionStart(startstring); appendstart = false; } AppendFailure(failure); break; case Reporter.FatalErrorCondition fatal: if (appendstart) { AppendSectionStart(startstring); appendstart = false; } AppendFatalErrorCondition(fatal); break; case Reporter.Info info: AppendInfo(info.Message); break; case Reporter.Section innersection: if (innersection.HasFailuresOrWarnings) { if (!appendstart) { AppendSectionEnd(endstring); appendstart = true; } AppendSection(innersection, startstring, endstring, level + 1); } break; case Reporter.Warning warning: if (appendstart) { AppendSectionStart(startstring); appendstart = false; } AppendWarning(warning); break; default: break; } } if (!appendstart) { AppendSectionEnd(endstring); appendstart = true; } }