// // System.Data.DataTable.cs // // Author: // Christopher Podurgiel (cpodurgiel@msn.com) // Daniel Morgan // Rodrigo Moya // // (C) Chris Podurgiel // (C) Ximian, Inc 2002 // using System; using System.Collections; using System.ComponentModel; using System.Globalization; using System.Runtime.Serialization; namespace System.Data { /// /// Represents one table of in-memory data. /// [Serializable] public class DataTable : ISerializable /* MarshalByValueComponent, IListSource, ISupportInitialize,*/ { private bool _caseSensitive; private DataColumnCollection _columnCollection; private ConstraintCollection _constraintCollection; // FIXME: temporarily commented // private DataSet _dataSet; // private DataView _defaultView; private string _displayExpression; private PropertyCollection _extendedProperties; private bool _hasErrors; private CultureInfo _locale; private int _minimumCapacity; private string _nameSpace; // FIXME: temporarily commented // private DataTableRelationCollection _childRelations; // private DataTableRelationCollection _parentRelations; private string _prefix; private DataColumn[] _primaryKey; private DataRowCollection _rows; private ISite _site; private string _tableName; private bool _containsListCollection; private string _encodedTableName; /// /// Initializes a new instance of the DataTable class with no arguments. /// public DataTable() { // _dataSet = null; // FIXME: temporarily commented // _defaultView = null; // FIXME: temporarily commented _columnCollection = new DataColumnCollection(this); //_constraintCollection = new ConstraintCollection(); TODO: uncomment after ConstraintCollection is built. _extendedProperties = null; _tableName = ""; _nameSpace = null; _caseSensitive = false; _displayExpression = null; _primaryKey = null; // FIXME: temporaily commented DataTableRelationCollection // _childRelations = new DataTableRelationCollection(); // _parentRelations = new DataTableRelationCollection(); //_nextRowID = 1; //_elementColumnCount = 0; //_caseSensitiveAmbient = true; //_culture = null; // _locale?? //_compareFlags = 25; // why 25?? //_fNestedInDataset = true; // what? //_encodedTableName = null; //?? //_xmlText = null; //?? //_colUnique = null; //?? //_textOnly = false; //?? //repeatableElement = false; //?? //zeroIntegers[] //zeroColumns[] //primaryIndex[] //delayedSetPrimaryKey = null; //?? } /// /// Intitalizes a new instance of the DataTable class with the specified table name. /// public DataTable(string tableName) { // _dataSet = null; // FIXME: temporarily commented // _defaultView = null; // FIXME: temporarily commented _columnCollection = new DataColumnCollection(this); //_constraintCollection = new ConstraintCollection(); TODO: uncomment after ConstraintCollection is built. _extendedProperties = null; _tableName = tableName; _nameSpace = null; _caseSensitive = false; _displayExpression = null; _primaryKey = null; // FIXME: temporarily commented DataTableRelationCollection // _childRelations = new DataTableRelationCollection(); // _parentRelations = new DataTableRelationCollection(); //_nextRowID = 1; //_elementColumnCount = 0; //_caseSensitiveAmbient = true; //_culture = null; // _locale?? //_compareFlags = 25; // why 25?? //_fNestedInDataset = true; // what? _encodedTableName = tableName; //_xmlText = null; //?? //_colUnique = null; //?? //_textOnly = false; //?? //repeatableElement = false; //?? //zeroIntegers[] //zeroColumns[] //primaryIndex[] //delayedSetPrimaryKey = null; //?? } /// /// Initializes a new instance of the DataTable class with the SerializationInfo and the StreamingContext. /// protected DataTable(SerializationInfo info, StreamingContext context) { // // TODO: Add constructor logic here // } /// /// Indicates whether string comparisons within the table are case-sensitive. /// public bool CaseSensitive { get { return _caseSensitive; } set { _caseSensitive = value; } } /// /// Gets the collection of child relations for this DataTable. /// public DataRelationCollection ChildRelations { get { // FIXME: temporarily commented to compile // return (DataRelationCollection)_childRelations; throw new NotImplementedException (); } } /// /// Gets the collection of columns that belong to this table. /// public DataColumnCollection Columns { get { return _columnCollection; } } /// /// Gets the collection of constraints maintained by this table. /// public ConstraintCollection Constraints { get { return _constraintCollection; } } /// /// Gets the DataSet that this table belongs to. /// /* * FIXME: temporarily commented, so we could get a * simple forward read only result set to read public DataSet DataSet { get { return _dataSet; } } /// /// Gets a customized view of the table which may /// include a filtered view, or a cursor position. /// public DataView DefaultView { get { return _defaultView; } } */ /// /// Gets or sets the expression that will return /// a value used to represent this table in the user interface. /// public string DisplayExpression { get { return _displayExpression; } set { _displayExpression = value; } } /// /// Gets the collection of customized user information. /// public PropertyCollection ExtendedProperties { get { return _extendedProperties; } } /// /// Gets a value indicating whether there are errors in /// any of the rows in any of the tables of the DataSet to /// which the table belongs. /// public bool HasErrors { get { return _hasErrors; } } /// /// Gets or sets the locale information used to /// compare strings within the table. /// public CultureInfo Locale { get { return _locale; } set { _locale = value; } } /// /// Gets or sets the initial starting size for this table. /// public int MinimumCapacity { get { return _minimumCapacity; } set { _minimumCapacity = value; } } /// /// Gets or sets the namespace for the XML represenation /// of the data stored in the DataTable. /// public string Namespace { get { return _nameSpace; } set { _nameSpace = value; } } /// /// Gets the collection of parent relations for /// this DataTable. /// public DataRelationCollection ParentRelations { get { // FIXME: temporarily commented to compile // return _parentRelations; throw new NotImplementedException (); } } /// /// Gets or sets the namespace for the XML represenation /// of the data stored in the DataTable. /// public string Prefix { get { return _prefix; } set { _prefix = value; } } /// /// Gets or sets an array of columns that function as /// primary keys for the data table. /// public DataColumn[] PrimaryKey { get { return _primaryKey; } set { _primaryKey = value; } } /// /// Gets the collection of rows that belong to this table. /// public DataRowCollection Rows { get { return _rows; } } /// /// Gets or sets an System.ComponentModel.ISite /// for the DataTable. /// public virtual ISite Site { get { return _site; } set { _site = value; } } /// /// Gets or sets the name of the the DataTable. /// public string TableName { get { return _tableName; } set { _tableName = value; } } /* FIXME: implement IListSource public bool IListSource.ContainsListCollection { get { return _containsListCollection; } } */ /// /// Commits all the changes made to this table since the /// last time AcceptChanges was called. /// public void AcceptChanges() { } /// /// Begins the initialization of a DataTable that is used /// on a form or used by another component. The initialization /// occurs at runtime. /// public void BeginInit() { } /// /// Turns off notifications, index maintenance, and /// constraints while loading data. /// public void BeginLoadData() { } /// /// Clears the DataTable of all data. /// public void Clear() { } /// /// Clones the structure of the DataTable, including /// all DataTable schemas and constraints. /// public virtual DataTable Clone() { return this; } /// /// Computes the given expression on the current rows that /// pass the filter criteria. /// public object Compute(string expression, string filter) { object obj = "a"; return obj; } /// /// Copies both the structure and data for this DataTable. /// public DataTable Copy() { return this; } /// /// Ends the initialization of a DataTable that is used /// on a form or used by another component. The /// initialization occurs at runtime. /// public void EndInit() { } /// /// Turns on notifications, index maintenance, and /// constraints after loading data. /// public void EndLoadData() { } /// /// Gets a copy of the DataTable that contains all /// changes made to it since it was loaded or /// AcceptChanges was last called. /// public DataTable GetChanges() { return this; } /// /// Gets a copy of the DataTable containing all /// changes made to it since it was last loaded, or /// since AcceptChanges was called, filtered by DataRowState. /// public DataTable GetChanges(DataRowState rowStates) { return this; } /// /// Gets an array of DataRow objects that contain errors. /// //public DataRow[] GetErrors() //{ // return _rows; //} /// /// This member supports the .NET Framework infrastructure /// and is not intended to be used directly from your code. /// //protected virtual Type GetRowType() //{ //} /// /// This member supports the .NET Framework infrastructure /// and is not intended to be used directly from your code. /// /* FIXME: implement IListSource public IList IListSource.GetList() { IList list = null; return list; } */ /// /// Copies a DataRow into a DataTable, preserving any /// property settings, as well as original and current values. /// public void ImportRow(DataRow row) { } /// /// This member supports the .NET Framework infrastructure /// and is not intended to be used directly from your code. /// void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { } /// /// Finds and updates a specific row. If no matching row /// is found, a new row is created using the given values. /// public DataRow LoadDataRow(object[] values, bool fAcceptChanges) { DataRow dataRow = null; return dataRow; } /// /// Creates a new DataRow with the same schema as the table. /// public DataRow NewRow() { DataRow dataRow = new DataRow(); dataRow.SetTable(this); return dataRow; } /// /// This member supports the .NET Framework infrastructure /// and is not intended to be used directly from your code. /// protected internal DataRow[] NewRowArray(int size) { DataRow[] dataRows = {null}; return dataRows; } /// /// Creates a new row from an existing row. /// /* DataRowBuilder is internal protected virtual DataRow NewRowFromBuilder(DataRowBuilder builder) { DataRow dataRow = null; return dataRow; } */ /// /// Raises the ColumnChanged event. /// protected virtual void OnColumnChanged(DataColumnChangeEventArgs e) { } /// /// Raises the ColumnChanging event. /// protected virtual void OnColumnChanging(DataColumnChangeEventArgs e) { } /// /// Raises the PropertyChanging event. /// protected internal virtual void OnPropertyChanging(PropertyChangedEventArgs pcevent) { } /// /// Notifies the DataTable that a DataColumn is being removed. /// protected internal virtual void OnRemoveColumn(DataColumn column) { } /// /// Raises the RowChanged event. /// protected virtual void OnRowChanged(DataRowChangeEventArgs e) { } /// /// Raises the RowChanging event. /// protected virtual void OnRowChanging(DataRowChangeEventArgs e) { } /// /// Raises the RowDeleted event. /// protected virtual void OnRowDeleted(DataRowChangeEventArgs e) { } /// /// Raises the RowDeleting event. /// protected virtual void OnRowDeleting(DataRowChangeEventArgs e) { } /// /// Rolls back all changes that have been made to the /// table since it was loaded, or the last time AcceptChanges /// was called. /// public void RejectChanges() { } /// /// Resets the DataTable to its original state. /// public virtual void Reset() { } /// /// Gets an array of all DataRow objects. /// public DataRow[] Select() { DataRow[] dataRows = {null}; return dataRows; } /// /// Gets an array of all DataRow objects that match /// the filter criteria in order of primary key (or /// lacking one, order of addition.) /// public DataRow[] Select(string filterExpression) { DataRow[] dataRows = {null}; return dataRows; } /// /// Gets an array of all DataRow objects that /// match the filter criteria, in the the /// specified sort order. /// public DataRow[] Select(string filterExpression, string sort) { DataRow[] dataRows = {null}; return dataRows; } /// /// Gets an array of all DataRow objects that match /// the filter in the order of the sort, that match /// the specified state. /// public DataRow[] Select(string filterExpression, string sort, DataViewRowState recordStates) { DataRow[] dataRows = {null}; return dataRows; } /// /// Gets the TableName and DisplayExpression, if /// there is one as a concatenated string. /// public override string ToString() { return ""; } /* FIXME: temporarily commented - so we can get a * a simple forward read only result set /// /// Occurs when after a value has been changed for /// the specified DataColumn in a DataRow. /// public event DataColumnChangeEventHandler ColumnChanged; /// /// Occurs when a value is being changed for the specified /// DataColumn in a DataRow. /// public event DataColumnChangeEventHandler ColumnChanging; /// /// Occurs after a DataRow has been changed successfully. /// public event DataRowChangeEventHandler RowChanged; /// /// Occurs when a DataRow is changing. /// public event DataRowChangeEventHandler RowChanging; /// /// Occurs after a row in the table has been deleted. /// public event DataRowChangeEventHandler RowDeleted; /// /// Occurs before a row in the table is about to be deleted. /// public event DataRowChangeEventHandler RowDeleting; */ } }