Skip to content

DiGi.Core.IO.Table.Classes

github-actions[bot] edited this page Jul 15, 2026 · 3 revisions

DiGi.Core.IO.Table.Classes Namespace

Classes

Column Class

Represents a column in a table, defining its index, name, and data type.

public class Column : DiGi.Core.Classes.SerializableObject, DiGi.Core.IO.Table.Interfaces.IColumn, DiGi.Core.IO.Table.Interfaces.ITableSerializableObject, DiGi.Core.IO.Table.Interfaces.ITableObject, DiGi.Core.IO.Interfaces.IIOObject, DiGi.Core.Interfaces.IObject, DiGi.Core.Interfaces.ISerializableObject, DiGi.Core.Interfaces.ICloneableObject<DiGi.Core.Interfaces.ISerializableObject>, DiGi.Core.Interfaces.ICloneableObject, DiGi.Core.Interfaces.INamedObject

Inheritance System.ObjectDiGi.Core.Classes.ObjectDiGi.Core.Classes.SerializableObject → Column

Derived
ExtendedColumn

Implements IColumn, ITableSerializableObject, ITableObject, DiGi.Core.IO.Interfaces.IIOObject, DiGi.Core.Interfaces.IObject, DiGi.Core.Interfaces.ISerializableObject, DiGi.Core.Interfaces.ICloneableObject<DiGi.Core.Interfaces.ISerializableObject>, DiGi.Core.Interfaces.ICloneableObject, DiGi.Core.Interfaces.INamedObject

Constructors

Column(Column) Constructor

Initializes a new instance of the Column class by copying another column.

public Column(DiGi.Core.IO.Table.Classes.Column? column);

Parameters

column Column

The source column to copy from.

Column(int) Constructor

Initializes a new instance of the Column class with a specified index.

public Column(int index);

Parameters

index System.Int32

The zero-based index of the column.

Column(int, Column) Constructor

Initializes a new instance of the Column class with a specified index and values copied from another column.

public Column(int index, DiGi.Core.IO.Table.Classes.Column? column);

Parameters

index System.Int32

The zero-based index of the column.

column Column

The source column to copy properties from.

Column(int, string, Type) Constructor

Initializes a new instance of the Column class with a specified index, name, and type.

public Column(int index, string? name, System.Type? type);

Parameters

index System.Int32

The zero-based index of the column.

name System.String

The name of the column.

type System.Type

The data type of the column.

Column(int, Type) Constructor

Initializes a new instance of the Column class with a specified index and type.

public Column(int index, System.Type? type);

Parameters

index System.Int32

The zero-based index of the column.

type System.Type

The data type of the column.

Column(string, Type) Constructor

Initializes a new instance of the Column class with a specified name and type.

public Column(string? name, System.Type? type);

Parameters

name System.String

The name of the column.

type System.Type

The data type of the column.

Column(JsonObject) Constructor

Initializes a new instance of the Column class from a JSON object.

public Column(System.Text.Json.Nodes.JsonObject? jsonObject);

Parameters

jsonObject System.Text.Json.Nodes.JsonObject

The JSON object containing column data.

Properties

Column.Index Property

Gets or sets the zero-based index of the column.

public int Index { get; set; }

Implements Index

Property Value

System.Int32

Column.Name Property

Gets the name of the column.

public string? Name { get; }

Implements Name

Property Value

System.String

Column.Type Property

Gets the data type of the column.

public System.Type? Type { get; }

Implements Type

Property Value

System.Type

Methods

Column.TryGetValidValue(object, object, bool) Method

Attempts to get a valid value for the column from the provided input, optionally attempting conversion.

public bool TryGetValidValue(object? @in, out object? @out, bool tryConvert=true);

Parameters

in System.Object

The input object to validate or convert.

out System.Object

When this method returns, contains the validated or converted value if successful; otherwise, null.

tryConvert System.Boolean

Whether to attempt conversion if the type is not directly assignable. Defaults to true.

Implements TryGetValidValue(object, object, bool)

Returns

System.Boolean
True if a valid value was obtained; otherwise, false.

ExtendedColumn Class

Represents an extended column in a table with additional metadata such as category and description.

public class ExtendedColumn : DiGi.Core.IO.Table.Classes.Column, DiGi.Core.IO.Table.Interfaces.IExtendedColumn, DiGi.Core.IO.Table.Interfaces.IColumn, DiGi.Core.IO.Table.Interfaces.ITableSerializableObject, DiGi.Core.IO.Table.Interfaces.ITableObject, DiGi.Core.IO.Interfaces.IIOObject, DiGi.Core.Interfaces.IObject, DiGi.Core.Interfaces.ISerializableObject, DiGi.Core.Interfaces.ICloneableObject<DiGi.Core.Interfaces.ISerializableObject>, DiGi.Core.Interfaces.ICloneableObject, DiGi.Core.Interfaces.INamedObject, DiGi.Core.Interfaces.IDescribableObject

Inheritance System.ObjectDiGi.Core.Classes.ObjectDiGi.Core.Classes.SerializableObjectColumn → ExtendedColumn

Implements IExtendedColumn, IColumn, ITableSerializableObject, ITableObject, DiGi.Core.IO.Interfaces.IIOObject, DiGi.Core.Interfaces.IObject, DiGi.Core.Interfaces.ISerializableObject, DiGi.Core.Interfaces.ICloneableObject<DiGi.Core.Interfaces.ISerializableObject>, DiGi.Core.Interfaces.ICloneableObject, DiGi.Core.Interfaces.INamedObject, DiGi.Core.Interfaces.IDescribableObject

Constructors

ExtendedColumn(ExtendedColumn) Constructor

Initializes a new instance of the ExtendedColumn class by copying another extended column.

public ExtendedColumn(DiGi.Core.IO.Table.Classes.ExtendedColumn? extendedColumn);

Parameters

extendedColumn ExtendedColumn

The source extended column to copy from.

ExtendedColumn(int) Constructor

Initializes a new instance of the ExtendedColumn class with a specified index.

public ExtendedColumn(int index);

Parameters

index System.Int32

The zero-based index of the column.

ExtendedColumn(int, ExtendedColumn) Constructor

Initializes a new instance of the ExtendedColumn class with a specified index and values copied from another extended column.

public ExtendedColumn(int index, DiGi.Core.IO.Table.Classes.ExtendedColumn? extendedColumn);

Parameters

index System.Int32

The zero-based index of the column.

extendedColumn ExtendedColumn

The source extended column to copy properties from.

ExtendedColumn(int, string, Type) Constructor

Initializes a new instance of the ExtendedColumn class with a specified index, name, and type.

public ExtendedColumn(int index, string? name, System.Type? type);

Parameters

index System.Int32

The zero-based index of the column.

name System.String

The name of the column.

type System.Type

The data type of the column.

ExtendedColumn(int, Type) Constructor

Initializes a new instance of the ExtendedColumn class with a specified index and type.

public ExtendedColumn(int index, System.Type? type);

Parameters

index System.Int32

The zero-based index of the column.

type System.Type

The data type of the column.

ExtendedColumn(string, Type) Constructor

Initializes a new instance of the ExtendedColumn class with a specified name and type.

public ExtendedColumn(string? name, System.Type? type);

Parameters

name System.String

The name of the column.

type System.Type

The data type of the column.

ExtendedColumn(string, Type, string, string) Constructor

Initializes a new instance of the ExtendedColumn class with specified metadata.

public ExtendedColumn(string? name, System.Type? type, string? category, string? description);

Parameters

name System.String

The name of the column.

type System.Type

The data type of the column.

category System.String

The category of the column.

description System.String

A description of the column's purpose.

ExtendedColumn(JsonObject) Constructor

Initializes a new instance of the ExtendedColumn class from a JSON object.

public ExtendedColumn(System.Text.Json.Nodes.JsonObject jsonObject);

Parameters

jsonObject System.Text.Json.Nodes.JsonObject

The JSON object containing column data.

Properties

ExtendedColumn.Category Property

Gets or sets the category of the column.

public string? Category { get; set; }

Implements Category

Property Value

System.String

ExtendedColumn.Description Property

Gets or sets a description for the column.

public string? Description { get; set; }

Implements Description

Property Value

System.String

Row Class

Represents a concrete implementation of a table row.

public sealed class Row : DiGi.Core.IO.Table.Classes.Row<DiGi.Core.IO.Table.Classes.Row>

Inheritance System.ObjectDiGi.Core.IO.Table.Classes.Row<Row> → Row

Constructors

Row(Row) Constructor

Initializes a new instance of the Row class by copying another row.

public Row(DiGi.Core.IO.Table.Classes.Row row);

Parameters

row Row

The source row to copy from.

Row(int) Constructor

Initializes a new instance of the Row class with a specified index.

public Row(int index);

Parameters

index System.Int32

The zero-based index of the row.

Row(int, IDictionary<int,object>) Constructor

Initializes a new instance of the Row class with a specified index and initial values.

public Row(int index, System.Collections.Generic.IDictionary<int,object?>? values);

Parameters

index System.Int32

The zero-based index of the row.

values System.Collections.Generic.IDictionary<System.Int32,System.Object>

A dictionary containing column indices and their corresponding values.

Methods

Row.Clone() Method

Creates a shallow copy of the current row.

public override DiGi.Core.IO.Table.Classes.Row? Clone();

Implements Clone()

Returns

Row
A new instance of the row with copied values.

Row<TRow> Class

Represents a base row in a table, providing functionality to manage column values by index.

public abstract class Row<TRow> : DiGi.Core.IO.Table.Interfaces.IRow<TRow>, DiGi.Core.IO.Table.Interfaces.IRow, DiGi.Core.IO.Table.Interfaces.ITableObject, DiGi.Core.IO.Interfaces.IIOObject, DiGi.Core.Interfaces.IObject, DiGi.Core.Interfaces.ICloneableObject<TRow>, DiGi.Core.Interfaces.ICloneableObject
    where TRow : DiGi.Core.IO.Table.Classes.Row<TRow>

Type parameters

TRow

The type of the row.

Inheritance System.Object → Row<TRow>

Derived
Row

Implements DiGi.Core.IO.Table.Interfaces.IRow<TRow>, IRow, ITableObject, DiGi.Core.IO.Interfaces.IIOObject, DiGi.Core.Interfaces.IObject, DiGi.Core.Interfaces.ICloneableObject<TRow>, DiGi.Core.Interfaces.ICloneableObject

Constructors

Row(Row) Constructor

Initializes a new instance of the Row<TRow> class by copying another row.

public Row(DiGi.Core.IO.Table.Classes.Row? row);

Parameters

row Row

The source row to copy from.

Row(int) Constructor

Initializes a new instance of the Row<TRow> class with a specified index.

public Row(int index);

Parameters

index System.Int32

The zero-based index of the row.

Row(int, Row) Constructor

Initializes a new instance of the Row<TRow> class with a specified index and values copied from another row.

public Row(int index, DiGi.Core.IO.Table.Classes.Row? row);

Parameters

index System.Int32

The zero-based index of the row.

row Row

The source row to copy properties from.

Row(int, IDictionary<int,object>) Constructor

Initializes a new instance of the Row<TRow> class with a specified index and initial values.

public Row(int index, System.Collections.Generic.IDictionary<int,object?>? values);

Parameters

index System.Int32

The zero-based index of the row.

values System.Collections.Generic.IDictionary<System.Int32,System.Object>

A dictionary containing column indices and their corresponding values.

Row(IDictionary<int,object>) Constructor

Initializes a new instance of the Row<TRow> class with initial values.

public Row(System.Collections.Generic.IDictionary<int,object?>? values);

Parameters

values System.Collections.Generic.IDictionary<System.Int32,System.Object>

A dictionary containing column indices and their corresponding values.

Properties

Row<TRow>.Count Property

Gets the number of values currently stored in the row.

public int Count { get; }

Property Value

System.Int32

Row<TRow>.Index Property

Gets the zero-based index of the row.

public int Index { get; }

Implements Index

Property Value

System.Int32

Row<TRow>.Indexes Property

Gets a set of all column indices that have values assigned in this row.

public System.Collections.Generic.HashSet<int> Indexes { get; }

Implements Indexes

Property Value

System.Collections.Generic.HashSet<System.Int32>

Row<TRow>.this[int] Property

Gets or sets the value for the specified column index.

public object? this[int index] { get; set; }

Parameters

index System.Int32

The zero-based index of the column.

Implements this[int]

Property Value

System.Object

Methods

Row<TRow>.Clone() Method

Creates a shallow copy of the current row.

public abstract TRow? Clone();

Implements Clone()

Returns

TRow
A new instance of the row with copied values.

Row<TRow>.GetValue<T>(int, T, bool) Method

Retrieves the value for the specified index, optionally converting it to the requested type.

public T? GetValue<T>(int index, T? defaultValue=default(T?), bool tryConvert=true);

Type parameters

T

The target type of the value.

Parameters

index System.Int32

The zero-based index of the column.

defaultValue T

The value to return if no value is found or conversion fails.

tryConvert System.Boolean

Whether to attempt converting the value to type <typeparam typeparamref="T" />.

Returns

T
The value at the specified index converted to <typeparam typeparamref="T" />, or the defaultValue.

Row<TRow>.GetValues() Method

Retrieves all values in the row as an array.

public object?[] GetValues();

Implements GetValues()

Returns

System.Object[]
An array of values where the array index corresponds to the column index.

Row<TRow>.RemoveValue(int) Method

Removes the value for the specified index from the row.

public bool RemoveValue(int index);

Parameters

index System.Int32

The zero-based index of the column to remove.

Implements RemoveValue(int)

Returns

System.Boolean
True if the value was successfully removed; otherwise, false.

Row<TRow>.TryGetValue<T>(int, T) Method

Attempts to retrieve and convert the value for the specified index to the requested type.

public bool TryGetValue<T>(int index, out T? value);

Type parameters

T

The target type of the value.

Parameters

index System.Int32

The zero-based index of the column.

value T

When this method returns, contains the value if retrieval and conversion succeeded; otherwise, the default value of T.

Implements TryGetValue<T>(int, T)

Returns

System.Boolean
True if the value was successfully retrieved and converted; otherwise, false.

Table Class

Represents a standard table with default Column and Row types.

Behavior and Architecture:

  1. Anemic Model Pattern: This class is designed as an anemic data model. It serves strictly as a structured data container holding columns of type Column and rows of type Row, containing minimal internal logic.

  2. Extension-Based Logic: All complex operations, queries, mutations, and business logic on this table are implemented as static extension methods in the static partial classes Query, Modify, and Create.

  3. Sorted Indexing: Columns and rows are stored in sorted dictionaries keyed by their index. This guarantees that columns and rows are always ordered sequentially by their index.

  4. Dynamic Shifting: Column removal operations shift all subsequent columns and their corresponding values in each row down by one index to maintain contiguous, zero-based column indexing.

  5. Default Value Fallback: Accessing a cell via the indexer this[rowIndex, columnIndex] returns the default value for the column's type if the cell does not exist or has not been populated.

  6. JSON Serialization: Designed for custom JSON serialization and deserialization using TableConverter which handles column schemas and row value arrays.

public class Table : DiGi.Core.IO.Table.Classes.Table<DiGi.Core.IO.Table.Classes.Column>

Inheritance System.ObjectDiGi.Core.IO.Table.Classes.Table<Column,Row>DiGi.Core.IO.Table.Classes.Table<Column> → Table

Constructors

Table() Constructor

Initializes a new instance of the Table class.

public Table();

Table(IEnumerable<Column>) Constructor

Initializes a new instance of the Table class with specified columns.

public Table(System.Collections.Generic.IEnumerable<DiGi.Core.IO.Table.Classes.Column> columns);

Parameters

columns System.Collections.Generic.IEnumerable<Column>

The collection of columns to add to the table.

Methods

Table.AddColumn() Method

Adds a new column with default settings.

public DiGi.Core.IO.Table.Classes.Column? AddColumn();

Returns

Column
The added column, or null if addition failed.

Table.AddColumn(string, Type) Method

Adds a new column with the specified name and type.

public DiGi.Core.IO.Table.Classes.Column? AddColumn(string? name, System.Type? type=null);

Parameters

name System.String

The name of the new column.

type System.Type

The type of the new column.

Returns

Column
The added column, or null if addition failed.

Table.AddColumn(Type) Method

Adds a new column with the specified type.

public DiGi.Core.IO.Table.Classes.Column? AddColumn(System.Type? type);

Parameters

type System.Type

The type of the new column.

Returns

Column
The added column, or null if addition failed.

Table.UpdateColumn(int, string, Type, bool) Method

Updates an existing column with a new name and type.

public DiGi.Core.IO.Table.Classes.Column? UpdateColumn(int index, string? name, System.Type? type=null, bool tryConvert=true);

Parameters

index System.Int32

The zero-based index of the column to update.

name System.String

The new name for the column.

type System.Type

The new type for the column.

tryConvert System.Boolean

Whether to attempt conversion of existing row values to the new column type.

Returns

Column
A clone of the updated column, or null if update failed.

Table<TColumn,TRow> Class

Represents a base table structure with generic column and row types.

Behavior and Architecture:

  1. Anemic Model Pattern: This class is designed as an anemic data model. It serves strictly as a structured data container holding columns and rows, containing minimal internal logic.

  2. Extension-Based Logic: All complex operations, queries, mutations, and business logic on this table are implemented as static extension methods in the static partial classes Query, Modify, and Create.

  3. Sorted Indexing: Columns and rows are stored in sorted dictionaries keyed by their index. This guarantees that columns and rows are always ordered sequentially by their index.

  4. Dynamic Shifting: Column removal operations (typically found in Modify extensions) shift all subsequent columns and their corresponding values in each row down by one index to maintain contiguous, zero-based column indexing.

  5. Default Value Fallback: Accessing a cell via the indexer this[rowIndex, columnIndex] returns the default value for the column's type if the cell does not exist or has not been populated.

  6. JSON Serialization: Designed for custom JSON serialization and deserialization using TableConverter which handles column schemas and row value arrays.

public abstract class Table<TColumn,TRow> : DiGi.Core.IO.Table.Interfaces.ITable<TColumn, TRow>, DiGi.Core.IO.Table.Interfaces.ITable, DiGi.Core.IO.Table.Interfaces.ITableObject, DiGi.Core.IO.Interfaces.IIOObject, DiGi.Core.Interfaces.IObject, System.Collections.Generic.IEnumerable<TRow>, System.Collections.IEnumerable
    where TColumn : DiGi.Core.IO.Table.Interfaces.IColumn
    where TRow : DiGi.Core.IO.Table.Interfaces.IRow<TRow>

Type parameters

TColumn

The type of the columns in the table.

TRow

The type of the rows in the table.

Inheritance System.Object → Table<TColumn,TRow>

Derived
Table<TColumn>

Implements DiGi.Core.IO.Table.Interfaces.ITable<TColumn,TRow>, ITable, ITableObject, DiGi.Core.IO.Interfaces.IIOObject, DiGi.Core.Interfaces.IObject, System.Collections.Generic.IEnumerable<TRow>, System.Collections.IEnumerable

Constructors

Table() Constructor

Initializes a new instance of the Table<TColumn,TRow> class.

public Table();

Table(IEnumerable<TColumn>) Constructor

Initializes a new instance of the Table<TColumn,TRow> class with specified columns.

public Table(System.Collections.Generic.IEnumerable<TColumn> columns);

Parameters

columns System.Collections.Generic.IEnumerable<TColumn>

The collection of columns to add to the table.

Properties

Table<TColumn,TRow>.ColumnCount Property

Gets the number of columns in the table.

public int ColumnCount { get; }

Property Value

System.Int32

Table<TColumn,TRow>.Columns Property

Gets the collection of columns in the table.

public System.Collections.Generic.IEnumerable<TColumn> Columns { get; }

Implements Columns

Property Value

System.Collections.Generic.IEnumerable<TColumn>

Table<TColumn,TRow>.RowCount Property

Gets the number of rows in the table.

public int RowCount { get; }

Property Value

System.Int32

Table<TColumn,TRow>.Rows Property

Gets the collection of rows in the table.

public System.Collections.Generic.IEnumerable<TRow> Rows { get; }

Implements Rows

Property Value

System.Collections.Generic.IEnumerable<TRow>

Table<TColumn,TRow>.this[int, int] Property

Gets or sets the value at the specified row and column indices.

public object? this[int rowIndex, int columnIndex] { get; }

Parameters

rowIndex System.Int32

The zero-based index of the row.

columnIndex System.Int32

The zero-based index of the column.

Property Value

System.Object

Table<TColumn,TRow>.this[TRow, TColumn] Property

Gets or sets the value for the specified row and column objects.

public object? this[TRow? row, TColumn? column] { get; }

Parameters

row TRow

The row object.

column TColumn

The column object.

Property Value

System.Object

Methods

Table<TColumn,TRow>.AddColumn(TColumn) Method

Adds a new column to the table.

public TColumn? AddColumn(TColumn? column);

Parameters

column TColumn

The column to add.

Implements AddColumn(UColumn)

Returns

TColumn
A clone of the added column with its index assigned, or null if addition failed.

Table<TColumn,TRow>.AddRow() Method

Adds a new row to the table with default values.

public TRow AddRow();

Returns

TRow
The newly created row.

Table<TColumn,TRow>.AddRow(IDictionary<int,object>) Method

Adds a new row to the table using column indices and values.

public TRow? AddRow(System.Collections.Generic.IDictionary<int,object?>? values);

Parameters

values System.Collections.Generic.IDictionary<System.Int32,System.Object>

A dictionary of column indices and their corresponding values.

Returns

TRow
The added row, or null if addition failed.

Table<TColumn,TRow>.AddRow(IDictionary<string,object>) Method

Adds a new row to the table using column names and values.

public TRow? AddRow(System.Collections.Generic.IDictionary<string,object?>? values);

Parameters

values System.Collections.Generic.IDictionary<System.String,System.Object>

A dictionary of column names and their corresponding values.

Returns

TRow
The added row, or null if addition failed.

Table<TColumn,TRow>.AddRow(IDictionary<string,object>, TextComparisonType, bool) Method

Adds a new row to the table using column names and values, with specific text comparison settings.

public TRow? AddRow(System.Collections.Generic.IDictionary<string,object?> values, DiGi.Core.Enums.TextComparisonType textComparisonType, bool caseSensitive);

Parameters

values System.Collections.Generic.IDictionary<System.String,System.Object>

A dictionary of column names and their corresponding values.

textComparisonType DiGi.Core.Enums.TextComparisonType

The type of text comparison to use for matching columns.

caseSensitive System.Boolean

Whether the search should be case-sensitive.

Returns

TRow
The added row, or null if addition failed.

Table<TColumn,TRow>.AddRow(IDictionary<string,object>, Func<string,string,bool>) Method

Adds a new row to the table using column names and values, with a custom column matching function.

public TRow? AddRow(System.Collections.Generic.IDictionary<string,object?>? values, System.Func<string?,string?,bool>? matchColumnFunc);

Parameters

values System.Collections.Generic.IDictionary<System.String,System.Object>

A dictionary of column names and their corresponding values.

matchColumnFunc System.Func<System.String,System.String,System.Boolean>

A function to determine if a provided key matches a column name.

Returns

TRow
The added row, or null if addition failed.

Table<TColumn,TRow>.AddRow(IEnumerable<object>) Method

Adds a new row to the table using an ordered collection of values.

public TRow? AddRow(System.Collections.Generic.IEnumerable<object?>? values);

Parameters

values System.Collections.Generic.IEnumerable<System.Object>

A sequence of values corresponding to columns in order.

Implements AddRow(IEnumerable<object>)

Returns

TRow
The added row, or null if addition failed.

Table<TColumn,TRow>.AddRow(TRow, bool) Method

Adds a new row to the table based on an existing row object.

public TRow? AddRow(TRow? row, bool tryConvert=true);

Parameters

row TRow

The source row.

tryConvert System.Boolean

Whether to attempt value conversion if types differ.

Returns

TRow
A clone of the added row, or null if addition failed.

Table<TColumn,TRow>.Clear() Method

Clears all rows and columns from the table.

public void Clear();

Table<TColumn,TRow>.ClearRows() Method

Clears all rows from the table, keeping the columns intact.

public void ClearRows();

Table<TColumn,TRow>.CreateRow(int, IDictionary<int,object>) Method

Creates a new row instance for the table. Must be implemented by derived classes.

protected abstract TRow CreateRow(int index, System.Collections.Generic.IDictionary<int,object?>? values=null);

Parameters

index System.Int32

The index to assign to the new row.

values System.Collections.Generic.IDictionary<System.Int32,System.Object>

Optional initial values for the row.

Returns

TRow
A newly created row instance.

Table<TColumn,TRow>.GetColumn(int) Method

Gets a column by its index.

public TColumn? GetColumn(int index);

Parameters

index System.Int32

The zero-based index of the column.

Returns

TColumn
A clone of the column if found; otherwise, default.

Table<TColumn,TRow>.GetColumnIndex(string, TextComparisonType, bool) Method

Gets the index of a column based on its name and specific text comparison settings.

public int GetColumnIndex(string name, DiGi.Core.Enums.TextComparisonType textComparisonType, bool caseSensitive);

Parameters

name System.String

The name of the column to search for.

textComparisonType DiGi.Core.Enums.TextComparisonType

The type of text comparison to use.

caseSensitive System.Boolean

Whether the search should be case-sensitive.

Returns

System.Int32
The zero-based index of the column, or -1 if not found.

Table<TColumn,TRow>.GetColumnIndex(string, Func<string,string,bool>) Method

Gets the index of a column based on its name.

public int GetColumnIndex(string? name, System.Func<string?,string?,bool>? matchColumnFunc=null);

Parameters

name System.String

The name of the column to search for.

matchColumnFunc System.Func<System.String,System.String,System.Boolean>

An optional custom function to match the name.

Returns

System.Int32
The zero-based index of the column, or -1 if not found.

Table<TColumn,TRow>.GetColumnValues(int) Method

Gets all values for a specific column index across all rows.

public object?[]? GetColumnValues(int columnIndex);

Parameters

columnIndex System.Int32

The zero-based index of the column.

Returns

System.Object[]
An array containing the values of the specified column for each row.

Table<TColumn,TRow>.GetColumnValues(TColumn) Method

Gets all values for a specific column across all rows.

public object?[]? GetColumnValues(TColumn? column);

Parameters

column TColumn

The column object.

Returns

System.Object[]
An array containing the values of the specified column for each row, or null if the column is null.

Table<TColumn,TRow>.GetEnumerator() Method

Returns an enumerator that iterates through the rows of the table.

public System.Collections.Generic.IEnumerator<TRow> GetEnumerator();

Implements GetEnumerator(), GetEnumerator()

Returns

System.Collections.Generic.IEnumerator<TRow>
An enumerator for the rows.

Table<TColumn,TRow>.GetNextColumnIndex() Method

Gets the next available index for a column.

public int GetNextColumnIndex();

Returns

System.Int32
The next index, or -1 if columns cannot be accessed.

Table<TColumn,TRow>.GetNextRowIndex() Method

Gets the next available index for a row.

public int GetNextRowIndex();

Returns

System.Int32
The next index, or -1 if rows cannot be accessed.

Table<TColumn,TRow>.GetRow(int) Method

Gets a row by its index.

public TRow? GetRow(int index);

Parameters

index System.Int32

The zero-based index of the row.

Returns

TRow
A clone of the row if found; otherwise, default.

Table<TColumn,TRow>.GetValue(int, int) Method

Gets the value at the specified row and column indices.

public object? GetValue(int rowIndex, int columnIndex);

Parameters

rowIndex System.Int32

The zero-based index of the row.

columnIndex System.Int32

The zero-based index of the column.

Returns

System.Object
The value at the specified position.

Table<TColumn,TRow>.GetValue(TRow, TColumn) Method

Gets the value for the specified row and column objects.

public object? GetValue(TRow? row, TColumn? column);

Parameters

row TRow

The row object.

column TColumn

The column object.

Returns

System.Object
The value at the intersection of the specified row and column.

Table<TColumn,TRow>.GetValue<T>(int, int) Method

Gets the value at the specified row and column indices, cast to the specified type.

public T? GetValue<T>(int rowIndex, int columnIndex);

Type parameters

T

The expected type of the value.

Parameters

rowIndex System.Int32

The zero-based index of the row.

columnIndex System.Int32

The zero-based index of the column.

Returns

T
The value cast to specified type, or default if not available or cast failed.

Table<TColumn,TRow>.GetValue<T>(TRow, TColumn) Method

Gets the value for the specified row and column objects, cast to the specified type.

public T? GetValue<T>(TRow? row, TColumn? column);

Type parameters

T

The expected type of the value.

Parameters

row TRow

The row object.

column TColumn

The column object.

Returns

T
The value cast to specified type, or default if not available or cast failed.

Table<TColumn,TRow>.GetValues() Method

Gets all values for all rows in the table.

public object?[]?[]? GetValues();

Returns

System.Object[][]
A jagged array containing all values of all rows.

Table<TColumn,TRow>.GetValues(int) Method

Gets all values for the specified row index.

public object?[]? GetValues(int rowIndex);

Parameters

rowIndex System.Int32

The zero-based index of the row.

Returns

System.Object[]
An array containing the values of the specified row, or null if the row is not found.

Table<TColumn,TRow>.RemoveColumn(int) Method

Removes a column at the specified index.

public bool RemoveColumn(int index);

Parameters

index System.Int32

The zero-based index of the column to remove.

Returns

System.Boolean
True if the column was removed; otherwise, false.

Table<TColumn,TRow>.RemoveColumns(IEnumerable<int>) Method

Removes columns at the specified indices and shifts remaining columns to fill gaps.

public System.Collections.Generic.List<int>? RemoveColumns(System.Collections.Generic.IEnumerable<int>? indexes);

Parameters

indexes System.Collections.Generic.IEnumerable<System.Int32>

The collection of zero-based indices of the columns to remove.

Returns

System.Collections.Generic.List<System.Int32>
A list of indices that were successfully removed, or null if input was null.

Table<TColumn,TRow>.RemoveRow(int) Method

Removes a row at the specified index.

public bool RemoveRow(int index);

Parameters

index System.Int32

The zero-based index of the row to remove.

Returns

System.Boolean
True if the row was removed; otherwise, false.

Table<TColumn,TRow>.RemoveRows(IEnumerable<int>) Method

Removes rows at the specified indices and shifts remaining rows to fill gaps.

public System.Collections.Generic.List<int>? RemoveRows(System.Collections.Generic.IEnumerable<int>? indexes);

Parameters

indexes System.Collections.Generic.IEnumerable<System.Int32>

The collection of zero-based indices of the rows to remove.

Returns

System.Collections.Generic.List<System.Int32>
A list of indices that were successfully removed, or null if input was null.

Table<TColumn,TRow>.SetValue(int, int, object, bool) Method

Sets the value at the specified row and column indices.

public bool SetValue(int rowIndex, int columnIndex, object? value, bool tryConvert=true);

Parameters

rowIndex System.Int32

The zero-based index of the row.

columnIndex System.Int32

The zero-based index of the column.

value System.Object

The value to set.

tryConvert System.Boolean

Whether to attempt conversion of the value to the column type.

Returns

System.Boolean
True if the value was successfully set; otherwise, false.

Table<TColumn,TRow>.TryGetColumn(string, TColumn, TextComparisonType, bool) Method

Attempts to get a column by its name.

public bool TryGetColumn(string? name, out TColumn? column, DiGi.Core.Enums.TextComparisonType textComparisonType=DiGi.Core.Enums.TextComparisonType.Equals, bool caseSensitive=true);

Parameters

name System.String

The name of the column.

column TColumn

When this method returns, contains the column if found; otherwise, null.

textComparisonType DiGi.Core.Enums.TextComparisonType

The type of text comparison to use.

caseSensitive System.Boolean

Whether the search should be case-sensitive.

Returns

System.Boolean
True if the column was found; otherwise, false.

Table<TColumn,TRow>.TryGetValidValue(int, object, object, bool) Method

Attempts to get a valid value for the specified column index.

public bool TryGetValidValue(int columnIndex, object? @in, out object? @out, bool tryConvert=true);

Parameters

columnIndex System.Int32

The zero-based index of the column.

in System.Object

The value to validate/convert.

out System.Object

When this method returns, contains the validated/converted value if successful; otherwise, null.

tryConvert System.Boolean

Whether to attempt conversion of the value to the column type.

Returns

System.Boolean
True if a valid value was obtained; otherwise, false.

Table<TColumn,TRow>.TryGetValue<T>(int, int, T) Method

Attempts to get a value from the specified row and column indices, cast to type T.

public bool TryGetValue<T>(int rowIndex, int columnIndex, out T? value);

Type parameters

T

The expected type of the value.

Parameters

rowIndex System.Int32

The zero-based index of the row.

columnIndex System.Int32

The zero-based index of the column.

value T

When this method returns, contains the value if found and cast successfully; otherwise, default.

Returns

System.Boolean
True if the value was found and cast successfully; otherwise, false.

Table<TColumn,TRow>.TryGetValue<T>(TRow, TColumn, T) Method

Attempts to get a value for the specified row and column objects, cast to type T.

public bool TryGetValue<T>(TRow? row, TColumn? column, out T? value);

Type parameters

T

The expected type of the value.

Parameters

row TRow

The row object.

column TColumn

The column object.

value T

When this method returns, contains the value if found and cast successfully; otherwise, default.

Returns

System.Boolean
True if the value was found and cast successfully; otherwise, false.

Table<TColumn,TRow>.UpdateColumn(int, TColumn, bool) Method

Updates an existing column at the specified index.

public TColumn? UpdateColumn(int index, TColumn column, bool tryConvert=true);

Parameters

index System.Int32

The zero-based index of the column to update.

column TColumn

The new column definition.

tryConvert System.Boolean

Whether to attempt conversion of existing row values to the new column type.

Returns

TColumn
A clone of the updated column, or null if update failed.

Table<TColumn,TRow>.UpdateRow(int, IDictionary<int,object>) Method

Updates a row at the specified index using column indices and values.

public TRow? UpdateRow(int index, System.Collections.Generic.IDictionary<int,object?>? values);

Parameters

index System.Int32

The zero-based index of the row to update.

values System.Collections.Generic.IDictionary<System.Int32,System.Object>

A dictionary of column indices and their corresponding values.

Returns

TRow
The updated row, or null if update failed.

Table<TColumn,TRow>.UpdateRow(int, IDictionary<string,object>, Func<string,string,bool>) Method

Updates a row at the specified index using column names and values.

public TRow? UpdateRow(int index, System.Collections.Generic.IDictionary<string,object?>? values, System.Func<string?,string?,bool>? func=null);

Parameters

index System.Int32

The zero-based index of the row to update.

values System.Collections.Generic.IDictionary<System.String,System.Object>

A dictionary of column names and their corresponding values.

func System.Func<System.String,System.String,System.Boolean>

An optional custom function to match column names.

Returns

TRow
The updated row, or null if update failed.

Table<TColumn,TRow>.UpdateRow(int, IEnumerable<object>) Method

Updates a row at the specified index using an ordered collection of values.

public TRow? UpdateRow(int index, System.Collections.Generic.IEnumerable<object>? values);

Parameters

index System.Int32

The zero-based index of the row to update.

values System.Collections.Generic.IEnumerable<System.Object>

A sequence of values corresponding to columns in order.

Returns

TRow
The updated row, or null if update failed.

Table<TColumn> Class

Represents a table with columns of type TColumn and rows of type Row.

public class Table<TColumn> : DiGi.Core.IO.Table.Classes.Table<TColumn, DiGi.Core.IO.Table.Classes.Row>
    where TColumn : DiGi.Core.IO.Table.Interfaces.IColumn

Type parameters

TColumn

The type of the columns in the table.

Inheritance System.ObjectDiGi.Core.IO.Table.Classes.Table<TColumn,Row> → Table<TColumn>

Derived
Table

Constructors

Table() Constructor

Initializes a new instance of the Table<TColumn> class.

public Table();

Table(IEnumerable<TColumn>) Constructor

Initializes a new instance of the Table<TColumn> class with specified columns.

public Table(System.Collections.Generic.IEnumerable<TColumn> columns);

Parameters

columns System.Collections.Generic.IEnumerable<TColumn>

The collection of columns to add to the table.

Methods

Table<TColumn>.CreateRow(int, IDictionary<int,object>) Method

Creates a new Row for this table.

protected override DiGi.Core.IO.Table.Classes.Row CreateRow(int index, System.Collections.Generic.IDictionary<int,object?>? values=null);

Parameters

index System.Int32

The index to assign to the new row.

values System.Collections.Generic.IDictionary<System.Int32,System.Object>

Optional initial values for the row.

Returns

Row
A newly created row instance.

TableConverter<UTable,UColumn,URow> Class

Provides custom JSON serialization and deserialization for tables.

public class TableConverter<UTable,UColumn,URow> : System.Text.Json.Serialization.JsonConverter<UTable>
    where UTable : DiGi.Core.IO.Table.Interfaces.ITable<UColumn, URow>, new()
    where UColumn : DiGi.Core.IO.Table.Interfaces.IColumn
    where URow : DiGi.Core.IO.Table.Interfaces.IRow<URow>

Type parameters

UTable

The type of the table.

UColumn

The type of the column.

URow

The type of the row.

Inheritance System.ObjectSystem.Text.Json.Serialization.JsonConverterSystem.Text.Json.Serialization.JsonConverter<UTable> → TableConverter<UTable,UColumn,URow>

Methods

TableConverter<UTable,UColumn,URow>.Read(Utf8JsonReader, Type, JsonSerializerOptions) Method

Reads and deserializes a table object from the provided UTF8 JSON reader.

public override UTable? Read(ref System.Text.Json.Utf8JsonReader utf8JsonReader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions jsonSerializerOptions);

Parameters

utf8JsonReader System.Text.Json.Utf8JsonReader

The UTF8 JSON reader to read from.

typeToConvert System.Type

The type of the object to convert to.

jsonSerializerOptions System.Text.Json.JsonSerializerOptions

The options for JSON deserialization.

Returns

UTable
The deserialized table object, or null if the value is null.

TableConverter<UTable,UColumn,URow>.Write(Utf8JsonWriter, UTable, JsonSerializerOptions) Method

Serializes a table object into the provided UTF8 JSON writer.

public override void Write(System.Text.Json.Utf8JsonWriter utf8JsonWriter, UTable table, System.Text.Json.JsonSerializerOptions jsonSerializerOptions);

Parameters

utf8JsonWriter System.Text.Json.Utf8JsonWriter

The UTF8 JSON writer to write to.

table UTable

The table object to serialize.

jsonSerializerOptions System.Text.Json.JsonSerializerOptions

The options for JSON serialization.

Clone this wiki locally