Class TabularText.Builder
Fluent builder for constructing TabularText instances with complex configuration. All settings are optional and default to sensible values.
Inherited Members
Namespace: Scylla.Core.Util
Assembly: ScyllaCore.dll
Syntax
public sealed class TabularText.Builder
Remarks
Obtain a builder instance via CreateBuilder(). Chain configuration methods and call Build() to produce the final TabularText object.
var table = TabularText.CreateBuilder()
.WithHeader("Name", "Value", "Type")
.WithSorting(0)
.WithDivider(" | ")
.WithColumnAlignment(1, TextAlignment.Right)
.Build();
table.AddRow("Alpha", "42", "int");
table.AddRow("Beta", "7", "float");
Console.WriteLine(table);
Methods
Build()
Builds and returns the configured TabularText instance using all settings accumulated by the fluent configuration calls on this builder.
Declaration
public TabularText Build()
Returns
| Type | Description |
|---|---|
| TabularText | A new TabularText instance initialized with the column count, header, sorting, footer, column lengths, divider, fill, row-leading, and per-column alignment settings specified on this builder. Per-column alignment overrides supplied via WithColumnAlignment(int, TextAlignment) are applied after construction. |
See Also
WithAlignment(TextAlignment)
Sets the default text alignment for all columns.
Declaration
public TabularText.Builder WithAlignment(TextAlignment alignment)
Parameters
| Type | Name | Description |
|---|---|---|
| TextAlignment | alignment | Default alignment. Default is Left. |
Returns
| Type | Description |
|---|---|
| TabularText.Builder | This builder instance for method chaining. |
WithColumnAlignment(int, TextAlignment)
Sets the text alignment for a specific column.
Declaration
public TabularText.Builder WithColumnAlignment(int columnIndex, TextAlignment alignment)
Parameters
| Type | Name | Description |
|---|---|---|
| int | columnIndex | Zero-based column index. |
| TextAlignment | alignment | Alignment for this column. |
Returns
| Type | Description |
|---|---|
| TabularText.Builder | This builder instance for method chaining. |
WithColumnCount(int)
Sets the number of columns. Ignored if WithHeader is called with a non-empty array.
Declaration
public TabularText.Builder WithColumnCount(int count)
Parameters
| Type | Name | Description |
|---|---|---|
| int | count | Number of columns. Must be at least 1. |
Returns
| Type | Description |
|---|---|
| TabularText.Builder | This builder instance for method chaining. |
WithDivider(string)
Sets the string used to separate columns.
Declaration
public TabularText.Builder WithDivider(string divider)
Parameters
| Type | Name | Description |
|---|---|---|
| string | divider | Column separator string. Default is single space. |
Returns
| Type | Description |
|---|---|
| TabularText.Builder | This builder instance for method chaining. |
WithFill(char)
Sets the character used for alignment padding.
Declaration
public TabularText.Builder WithFill(char fill)
Parameters
| Type | Name | Description |
|---|---|---|
| char | fill | Fill character. Default is space. |
Returns
| Type | Description |
|---|---|
| TabularText.Builder | This builder instance for method chaining. |
WithFooter()
Marks the last row added as a footer row, displayed with a divider above it.
Declaration
public TabularText.Builder WithFooter()
Returns
| Type | Description |
|---|---|
| TabularText.Builder | This builder instance for method chaining. |
WithHeader(params string[])
Sets the header row. The number of elements determines the column count.
Declaration
public TabularText.Builder WithHeader(params string[] header)
Parameters
| Type | Name | Description |
|---|---|---|
| string[] | header | Header strings for each column. |
Returns
| Type | Description |
|---|---|
| TabularText.Builder | This builder instance for method chaining. |
WithMaxColumnLength(int)
Sets the maximum character length for column content. Longer strings are truncated with ellipsis.
Declaration
public TabularText.Builder WithMaxColumnLength(int maxLength)
Parameters
| Type | Name | Description |
|---|---|---|
| int | maxLength | Maximum length. Use 0 for unlimited. |
Returns
| Type | Description |
|---|---|
| TabularText.Builder | This builder instance for method chaining. |
WithRowLeading(string)
Sets a prefix string for each row.
Declaration
public TabularText.Builder WithRowLeading(string leading)
Parameters
| Type | Name | Description |
|---|---|---|
| string | leading | Row prefix string. Default is empty. |
Returns
| Type | Description |
|---|---|
| TabularText.Builder | This builder instance for method chaining. |
WithSorting(int)
Enables alphabetical sorting of data rows by the specified column.
Declaration
public TabularText.Builder WithSorting(int sortColumn = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| int | sortColumn | Zero-based column index to sort by. Default is 0. |
Returns
| Type | Description |
|---|---|
| TabularText.Builder | This builder instance for method chaining. |