public virtual void WriteAllValues(IConsoleOutputter consoleOutputter, ViewPort viewPort, ColumnDetails columnConstraints, int lineOrdinal, bool displayNulls = true, string verticalSeparator = "|", string truncationIdentifier = "...") { foreach (ICellContent item in this.GetCellContentByLineOrdinal(lineOrdinal)) { string data = columnConstraints.GetFormattedValue(item.Value, viewPort, displayNulls, verticalSeparator); if (IsOverlyLargeColumn(columnConstraints, viewPort, verticalSeparator)) { if (data.Length > viewPort.Width) { if (item.ForegroundColor.HasValue) { consoleOutputter.SetForegroundColor(item.ForegroundColor.Value); } consoleOutputter.Write(data.Substring(0, viewPort.Width - (verticalSeparator.Length * 2) - Environment.NewLine.Length - truncationIdentifier.Length)); consoleOutputter.SetForegroundColor(ConsoleColor.Yellow); consoleOutputter.BackgroundColor = ConsoleColor.Black; consoleOutputter.Write(truncationIdentifier); consoleOutputter.ResetColor(); } else { if (item.ForegroundColor.HasValue) { consoleOutputter.SetForegroundColor(item.ForegroundColor.Value); } consoleOutputter.Write(data); consoleOutputter.ResetColor(); } } else if (data.Contains("[null]")) { consoleOutputter.SetForegroundColor(ConsoleColor.DarkGray); consoleOutputter.Write(data); consoleOutputter.ResetColor(); } else { if (item.ForegroundColor.HasValue) { consoleOutputter.SetForegroundColor(item.ForegroundColor.Value); } consoleOutputter.Write(data); consoleOutputter.ResetColor(); } } }
private void WriteValues(ViewModel viewModel, bool displayNulls) { for (int i = 0; i < viewModel.Rows.Count; i++) { object[] row = viewModel.Rows.ElementAt(i); Console.Write(verticalSeparator); for (int j = 0; j < viewModel.Columns.Count(); j++) { ColumnDetails header = viewModel.Columns.ElementAt(j); Console.Write(header.GetFormattedValue(row[j], new ViewPort(), displayNulls, verticalSeparator)); Console.Write(verticalSeparator); } Console.WriteLine(); } }