private Table GenerateConciseTable(Dictionary <DnsServer, List <DnsResponse> > results, RunOptions options, string title = null) { var table = new Table() .Border(TableBorder.MinimalHeavyHead) .BorderColor(Color.White) .AddColumn(new TableColumn($"[green][u]{i18n.dug.Table_Record_Type}[/][/]").Centered()) .AddColumn(new TableColumn($"[green][u]{i18n.dug.Table_Value}[/][/]").Centered()) .AddColumn(new TableColumn($"[green][u]{i18n.dug.Table_Continent_Consensus}[/][/]").LeftAligned()); if (!string.IsNullOrEmpty(title)) { table.Title = new TableTitle(title); } foreach (var queryType in options.ParsedQueryTypes) { var resultsWithContinentCounts = new Dictionary <string, Dictionary <ContinentCodes, int> >(); foreach (var result in results) { var server = result.Key; var responses = result.Value; var relevantResponse = responses.Single(res => (QueryType)res.RecordType == queryType); var answerString = TemplateHelper.GetAnswersString(relevantResponse); if (resultsWithContinentCounts.ContainsKey(answerString)) { if (resultsWithContinentCounts[answerString].ContainsKey(server.ContinentCode)) { resultsWithContinentCounts[answerString][server.ContinentCode]++; } else { resultsWithContinentCounts[answerString][server.ContinentCode] = 1; } } else { resultsWithContinentCounts[answerString] = new Dictionary <ContinentCodes, int>(new ContinentCodeComparer()) { { server.ContinentCode, 1 } }; } } var continentTotals = new Dictionary <ContinentCodes, int>(new ContinentCodeComparer()); foreach (ContinentCodes continent in ContinentCodes.Continents) { var totalContinentInstances = resultsWithContinentCounts.Sum(res => res.Value.GetValueOrDefault(continent)); continentTotals[continent] = totalContinentInstances; } foreach (var groupedResult in resultsWithContinentCounts) { table.AddRow( new Text(queryType.ToString()), new Markup(MarkupHelper.FormatDnsResponseMarkup(groupedResult.Key, options.Hostname)), new Markup(MarkupHelper.FormatConsensusMarkup(groupedResult.Value, continentTotals)) ); table.AddEmptyRow(); } table.AddRow(new Rule().HeavyBorder(), new Rule().HeavyBorder(), new Rule().HeavyBorder()); } return(table); }