using System.Data;
namespace Terminal.Gui;
///
/// implementation that wraps a . This class is
/// mutable: changes are permitted to the wrapped .
///
public class DataTableSource : ITableSource
{
/// Creates a new instance based on the data in .
///
public DataTableSource (DataTable table) { DataTable = table; }
/// The data table this source wraps.
public DataTable DataTable { get; }
///
public object this [int row, int col] => DataTable.Rows [row] [col];
///
public int Rows => DataTable.Rows.Count;
///
public int Columns => DataTable.Columns.Count;
///
public string [] ColumnNames => DataTable.Columns.Cast ().Select (c => c.Caption).ToArray ();
}