Skip to main content

TableParserExtensions

A static class in Root.Township, TableParser.

Extension methods that format lists of objects as plain text tables with padded columns, for console and log output.

Fields​

1 private and internal field
MemberWhat it is
private static StringBuilder stringBuilderShared builder reused by every call, so this isn't thread safe.

Methods​

MemberWhat it is
static string ToStringTable(IEnumerable values)Builds a text table from values, using public properties (skipping JsonIgnore, ordered by TableOrder), selectors or a string grid. Prints "Empty Table" for no rows.
static string ToStringTable<T>(IEnumerable<T> values, string[] columnHeaders, params Func<T, object>[] valueSelectors)Builds a text table from values, using public properties (skipping JsonIgnore, ordered by TableOrder), selectors or a string grid. Prints "Empty Table" for no rows.
static string ToStringTable<T>(T[] values, string[] columnHeaders, params Func<T, object>[] valueSelectors)Builds a text table from values, using public properties (skipping JsonIgnore, ordered by TableOrder), selectors or a string grid. Prints "Empty Table" for no rows.
static string ToStringTable(string[,] arrValues)Builds a text table from values, using public properties (skipping JsonIgnore, ordered by TableOrder), selectors or a string grid. Prints "Empty Table" for no rows.
static string ToStringTable<T>(IEnumerable<T> values, params Expression<Func<T, object>>[] valueSelectors)Builds a text table from values, using public properties (skipping JsonIgnore, ordered by TableOrder), selectors or a string grid. Prints "Empty Table" for no rows.
2 private and internal methods
MemberWhat it is
private static int[] GetMaxColumnsWidth(string[,] arrValues)Returns the widest cell length in each column.
private static PropertyInfo GetProperty<T>(Expression<Func<T, object>> expression)Gets the property a selector expression points at, used for column headers.