public void WriteTable(IBufferedWriter buffer) { int padding = 5; // write header text row if (Columns.Count > 0) { buffer.Out.Standard.WriteLineAsync(); buffer.Out.Standard.WriteAsync(string.Empty.PadLeft(_leftPadding)); foreach (var column in Columns) { buffer.Out.Standard.WriteAsync(column.HeaderText.PadRight(column.ColumnWidth + padding)); } buffer.Out.Standard.WriteLineAsync(); // write header underline row buffer.Out.Standard.WriteAsync(string.Empty.PadLeft(_leftPadding)); foreach (var column in Columns) { buffer.Out.Standard.WriteAsync(string.Empty.PadRight(column.ColumnWidth, '=').PadRight(column.ColumnWidth + padding)); } buffer.Out.Standard.WriteLineAsync(); // write rows var writer = buffer.Out.Accent1; foreach (var row in Rows) { if (writer == buffer.Out.Accent1) { writer = buffer.Out.Standard; } else { writer = buffer.Out.Accent1; } for (int i = 0; i < row.RowHeight; i++) { buffer.Out.Standard.WriteAsync(string.Empty.PadLeft(_leftPadding)); foreach (var column in Columns) { if (row.Values[column.Index].Lines.Count < i + 1) { writer.WriteAsync(string.Empty.PadRight(column.ColumnWidth + padding)); } else { writer.WriteAsync(row.Values[column.Index].Lines[i].PadRight(column.ColumnWidth + padding)); } } buffer.Out.Standard.WriteLineAsync(); } } buffer.Flush(); } }
public HostWriterCollection(Action <string, HostWriterContext> onWriteAction, IBufferedWriter buffer) { this.onWriteAction = onWriteAction; Standard = new HostWriter(onWriteAction, Constants.COLOR_STANDARD_FOREGROUND, Constants.COLOR_STANDARD_HIGHLIGHT); Warning = new HostWriter(onWriteAction, Constants.COLOR_WARNING_FOREGROUND, Constants.COLOR_WARNING_HIGHLIGHT); Error = new HostWriter(onWriteAction, Constants.COLOR_ERROR_FOREGROUND, Constants.COLOR_ERROR_HIGHLIGHT); Debug = new HostWriter(onWriteAction, Constants.COLOR_DEBUG_FOREGROUND, Constants.COLOR_DEBUG_HIGHLIGHT); Verbose = new HostWriter(onWriteAction, Constants.COLOR_VERBOSE_FOREGROUND, Constants.COLOR_VERBOSE_HIGHLIGHT); Accent1 = new HostWriter(onWriteAction, Constants.COLOR_ACCENT1_FOREGROUND, Constants.COLOR_ACCENT1_HIGHLIGHT); Accent2 = new HostWriter(onWriteAction, Constants.COLOR_ACCENT2_FOREGROUND, Constants.COLOR_ACCENT2_HIGHLIGHT); Accent3 = new HostWriter(onWriteAction, Constants.COLOR_ACCENT3_FOREGROUND, Constants.COLOR_ACCENT3_HIGHLIGHT); Accent4 = new HostWriter(onWriteAction, Constants.COLOR_ACCENT4_FOREGROUND, Constants.COLOR_ACCENT4_HIGHLIGHT); Accent5 = new HostWriter(onWriteAction, Constants.COLOR_ACCENT5_FOREGROUND, Constants.COLOR_ACCENT5_HIGHLIGHT); Object = new ObjectWriter(this, buffer); }
internal ObjectWriter(IWriterCollection writers, IBufferedWriter buffer) { _writers = writers; _buffer = buffer; }