From 5957b40b3b5db0ed3deeb4c7e6e7a2911eb5baba Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Sat, 11 May 2002 19:31:30 +0000 Subject: [PATCH] 2002-05-11 Rodrigo Moya * System.Data/DataTable.cs (Clear): implemented. (DataTable): removed repeated code in constructors, and call the basic constructor from the others. * System.Data/DataColumn.cs: some tweaks. * System.Data/DataRow.cs (RowState): implemented. (CancelEdit): set rowState property back to Unchanged. (RejectChanges): call CancelEdit. (Delete): set rowState to Deleted. svn path=/trunk/mcs/; revision=4534 --- mcs/class/System.Data/ChangeLog | 13 ++ .../System.Data/System.Data/DataColumn.cs | 118 ++++++---------- mcs/class/System.Data/System.Data/DataRow.cs | 132 +++++++++++------- .../System.Data/DataRowCollection.cs | 38 ++--- .../System.Data/System.Data/DataTable.cs | 129 +++++------------ 5 files changed, 190 insertions(+), 240 deletions(-) diff --git a/mcs/class/System.Data/ChangeLog b/mcs/class/System.Data/ChangeLog index bdebf288584..314506d11f4 100644 --- a/mcs/class/System.Data/ChangeLog +++ b/mcs/class/System.Data/ChangeLog @@ -1,3 +1,16 @@ +2002-05-11 Rodrigo Moya + + * System.Data/DataTable.cs (Clear): implemented. + (DataTable): removed repeated code in constructors, and call the + basic constructor from the others. + + * System.Data/DataColumn.cs: some tweaks. + + * System.Data/DataRow.cs (RowState): implemented. + (CancelEdit): set rowState property back to Unchanged. + (RejectChanges): call CancelEdit. + (Delete): set rowState to Deleted. + 2002-05-11 Daniel Morgan * System.Data.build: added copy of System.Data.dll to Test directory diff --git a/mcs/class/System.Data/System.Data/DataColumn.cs b/mcs/class/System.Data/System.Data/DataColumn.cs index d7f1bf55a07..91d99f31ec3 100644 --- a/mcs/class/System.Data/System.Data/DataColumn.cs +++ b/mcs/class/System.Data/System.Data/DataColumn.cs @@ -19,7 +19,7 @@ namespace System.Data /// /// Summary description for DataColumn. /// - public class DataColumn + public class DataColumn : MarshalByValueComponent { #region Fields @@ -28,9 +28,7 @@ namespace System.Data private long autoIncrementSeed = 0; private long autoIncrementStep = 1; private string caption = null; - // FIXME: what does ms.net do for default of columnMapping - // when not specified by the constructor? - private MappingType columnMapping = MappingType.SimpleContent; // default? + private MappingType columnMapping = MappingType.Element; private string columnName = null; private Type dataType = null; private object defaultValue = null; @@ -59,8 +57,7 @@ namespace System.Data public DataColumn(string columnName, Type dataType): this(columnName) { - if(dataType == null) - { + if(dataType == null) { throw new ArgumentNullException(); } @@ -85,12 +82,10 @@ namespace System.Data public bool AllowDBNull { - get - { + get { return allowDBNull; } - set - { + set { allowDBNull = value; } } @@ -106,12 +101,10 @@ namespace System.Data /// public bool AutoIncrement { - get - { + get { return autoIncrement; } - set - { + set { autoIncrement = value; if(autoIncrement == true) { @@ -132,75 +125,63 @@ namespace System.Data public long AutoIncrementSeed { - get - { + get { return autoIncrementSeed; } - set - { + set { autoIncrementSeed = value; } } public long AutoIncrementStep { - get - { + get { return autoIncrementStep; } - set - { + set { autoIncrementStep = value; } } public string Caption { - get - { + get { if(caption == null) return columnName; else return caption; } - set - { + set { caption = value; } } public virtual MappingType ColumnMapping { - get - { + get { return columnMapping; } - set - { + set { columnMapping = value; } } public string ColumnName { - get - { + get { return columnName; } - set - { + set { columnName = value; } } public Type DataType { - get - { + get { return dataType; } - set - { + set { if(AutoIncrement == true && Type.GetTypeCode(value) != TypeCode.Int32) { @@ -216,56 +197,47 @@ namespace System.Data /// When AutoIncrement is set to true, there can be no default value. public object DefaultValue { - get - { + get { return defaultValue; } - set - { + set { defaultValue = value; } } public string Expression { - get - { + get { return expression; } - set - { + set { expression = value; } } public PropertyCollection ExtendedProperties { - get - { + get { return extendedProperties; } } public int MaxLength { - get - { + get { return maxLength; } - set - { + set { maxLength = value; } } public string Namespace { - get - { + get { return nameSpace; } - set - { + set { nameSpace = value; } } @@ -273,52 +245,44 @@ namespace System.Data //Need a good way to set the Ordinal when the column is added to a columnCollection. public int Ordinal { - get - { + get { return ordinal; } } public string Prefix { - get - { + get { return prefix; } - set - { + set { prefix = value; } } public bool ReadOnly { - get - { + get { return readOnly; } - set - { + set { readOnly = value; } } public DataTable Table { - get - { + get { return table; } } public bool Unique { - get - { + get { return unique; } - set - { + set { unique = value; } } @@ -352,14 +316,10 @@ namespace System.Data [MonoTODO] public override string ToString() { - if(expression != null && expression != string.Empty) - { + if (expression != null) return expression; - } - else - { - return columnName; - } + + return columnName; } [MonoTODO] diff --git a/mcs/class/System.Data/System.Data/DataRow.cs b/mcs/class/System.Data/System.Data/DataRow.cs index 6a2814e606b..45ed449db81 100644 --- a/mcs/class/System.Data/System.Data/DataRow.cs +++ b/mcs/class/System.Data/System.Data/DataRow.cs @@ -21,16 +21,17 @@ namespace System.Data { #region Fields - private ArrayList columns = new ArrayList(); - private ArrayList columnNames = new ArrayList(); + private ArrayList columns = new ArrayList (); + private ArrayList columnNames = new ArrayList (); private DataTable table = null; + private DataRowState rowState = DataRowState.Unchanged; #endregion #region Methods [MonoTODO] - public void AcceptChanges() { + public void AcceptChanges () { throw new NotImplementedException (); } @@ -41,7 +42,8 @@ namespace System.Data [MonoTODO] public void CancelEdit() { - throw new NotImplementedException (); + // FIXME: throw changes away + rowState = DataRowState.Unchanged; } [MonoTODO] @@ -49,9 +51,8 @@ namespace System.Data throw new NotImplementedException (); } - [MonoTODO] public void Delete() { - throw new NotImplementedException (); + rowState = DataRowState.Deleted; } [MonoTODO] @@ -60,142 +61,142 @@ namespace System.Data } [MonoTODO] - public DataRow[] GetChildRows(DataRelation dr) { + public DataRow[] GetChildRows (DataRelation dr) { throw new NotImplementedException (); } [MonoTODO] - public DataRow[] GetChildRows(string s) { + public DataRow[] GetChildRows (string s) { throw new NotImplementedException (); } [MonoTODO] - public DataRow[] GetChildRows(DataRelation dr, DataRowVersion version) { + public DataRow[] GetChildRows (DataRelation dr, DataRowVersion version) { throw new NotImplementedException (); } [MonoTODO] - public DataRow[] GetChildRows(string s, DataRowVersion version) { + public DataRow[] GetChildRows (string s, DataRowVersion version) { throw new NotImplementedException (); } [MonoTODO] - public string GetColumnError(DataColumn col) { + public string GetColumnError (DataColumn col) { throw new NotImplementedException (); } [MonoTODO] - public string GetColumnError(int index) { + public string GetColumnError (int index) { throw new NotImplementedException (); } [MonoTODO] - public string GetColumnError(string s) { + public string GetColumnError (string s) { throw new NotImplementedException (); } [MonoTODO] - public DataColumn[] GetColumnsInError() { + public DataColumn[] GetColumnsInError () { throw new NotImplementedException (); } [MonoTODO] - public DataRow GetParentRow(DataRelation dr) { + public DataRow GetParentRow (DataRelation dr) { throw new NotImplementedException (); } [MonoTODO] - public DataRow GetParentRow(string s) { + public DataRow GetParentRow (string s) { throw new NotImplementedException (); } [MonoTODO] - public DataRow GetParentRow(DataRelation dr, DataRowVersion version) { + public DataRow GetParentRow (DataRelation dr, DataRowVersion version) { throw new NotImplementedException (); } [MonoTODO] - public DataRow GetParentRow(string s, DataRowVersion version) { + public DataRow GetParentRow (string s, DataRowVersion version) { throw new NotImplementedException (); } [MonoTODO] - public DataRow[] GetParentRows(DataRelation dr) { + public DataRow[] GetParentRows (DataRelation dr) { throw new NotImplementedException (); } [MonoTODO] - public DataRow[] GetParentRows(string s) { + public DataRow[] GetParentRows (string s) { throw new NotImplementedException (); } [MonoTODO] - public DataRow[] GetParentRows(DataRelation dr, DataRowVersion version) { + public DataRow[] GetParentRows (DataRelation dr, DataRowVersion version) { throw new NotImplementedException (); } [MonoTODO] - public DataRow[] GetParentRows(string s, DataRowVersion version) { + public DataRow[] GetParentRows (string s, DataRowVersion version) { throw new NotImplementedException (); } [MonoTODO] - public bool HasVersion(DataRowVersion version) { + public bool HasVersion (DataRowVersion version) { throw new NotImplementedException (); } [MonoTODO] - public bool IsNull(DataColumn dc) { + public bool IsNull (DataColumn dc) { throw new NotImplementedException (); } [MonoTODO] - public bool IsNull(int i) { + public bool IsNull (int i) { throw new NotImplementedException (); } [MonoTODO] - public bool IsNull(string s) { + public bool IsNull (string s) { throw new NotImplementedException (); } [MonoTODO] - public bool IsNull(DataColumn dc, DataRowVersion version) { + public bool IsNull (DataColumn dc, DataRowVersion version) { throw new NotImplementedException (); } [MonoTODO] - public void RejectChanges() { - throw new NotImplementedException (); + public void RejectChanges () { + CancelEdit (); } [MonoTODO] - public void SetColumnError(DataColumn dc, string err) { + public void SetColumnError (DataColumn dc, string err) { throw new NotImplementedException (); } [MonoTODO] - public void SetColumnError(int i, string err) { + public void SetColumnError (int i, string err) { throw new NotImplementedException (); } [MonoTODO] - public void SetColumnError(string a, string err) { + public void SetColumnError (string a, string err) { throw new NotImplementedException (); } [MonoTODO] - public void SetParentRow(DataRow row) { + public void SetParentRow (DataRow row) { throw new NotImplementedException (); } [MonoTODO] - public void SetParentRow(DataRow row, DataRelation rel) { + public void SetParentRow (DataRow row, DataRelation rel) { throw new NotImplementedException (); } [MonoTODO] - protected void SetNull(DataColumn column) { + protected void SetNull (DataColumn column) { throw new NotImplementedException (); } @@ -205,67 +206,96 @@ namespace System.Data public bool HasErrors { [MonoTODO] - get { throw new NotImplementedException (); } + get { + throw new NotImplementedException (); + } } public object this[string s] { [MonoTODO] - get { throw new NotImplementedException (); } + get { + throw new NotImplementedException (); + } [MonoTODO] - set { throw new NotImplementedException (); } + set { + throw new NotImplementedException (); + } } public object this[DataColumn dc] { [MonoTODO] - get { throw new NotImplementedException (); } + get { + throw new NotImplementedException (); + } [MonoTODO] - set { throw new NotImplementedException (); } + set { + throw new NotImplementedException (); + } } public object this[int i] { [MonoTODO] - get { throw new NotImplementedException (); } + get { + throw new NotImplementedException (); + } [MonoTODO] - set { throw new NotImplementedException (); } + set { + throw new NotImplementedException (); + } } public object this[string s, DataRowVersion version] { [MonoTODO] - get { throw new NotImplementedException (); } + get { + throw new NotImplementedException (); + } } public object this[DataColumn dc, DataRowVersion version] { [MonoTODO] - get { throw new NotImplementedException (); } + get { + throw new NotImplementedException (); + } } public object this[int i, DataRowVersion version] { [MonoTODO] - get { throw new NotImplementedException (); } + get { + throw new NotImplementedException (); + } } public object[] ItemArray { [MonoTODO] - get { throw new NotImplementedException (); } + get { + throw new NotImplementedException (); + } [MonoTODO] - set { throw new NotImplementedException (); } + set { + throw new NotImplementedException (); + } } public string RowError { [MonoTODO] - get { throw new NotImplementedException (); } + get { + throw new NotImplementedException (); + } [MonoTODO] - set { throw new NotImplementedException (); } + set { + throw new NotImplementedException (); + } } public DataRowState RowState { - [MonoTODO] - get { throw new NotImplementedException (); } + get { + return rowState; + } } public DataTable Table { diff --git a/mcs/class/System.Data/System.Data/DataRowCollection.cs b/mcs/class/System.Data/System.Data/DataRowCollection.cs index d111d99aced..575d21b8119 100644 --- a/mcs/class/System.Data/System.Data/DataRowCollection.cs +++ b/mcs/class/System.Data/System.Data/DataRowCollection.cs @@ -13,10 +13,10 @@ using System.ComponentModel; namespace System.Data { - /// - /// Collection of DataRows in a DataTable + /// + /// Collection of DataRows in a DataTable /// - [Serializable] + [Serializable] public class DataRowCollection : InternalDataCollectionBase { private ArrayList rows = null; @@ -29,8 +29,8 @@ namespace System.Data } } - [MonoTODO] - public void Add(DataRow row) { + [MonoTODO] + public void Add (DataRow row) { rows.Add(row); } @@ -39,7 +39,7 @@ namespace System.Data throw new NotImplementedException (); } - [MonoTODO] + [MonoTODO] public void Clear() { throw new NotImplementedException (); } @@ -59,27 +59,27 @@ namespace System.Data throw new NotImplementedException (); } - [MonoTODO] + [MonoTODO] public void InsertAt(DataRow row, int pos) { throw new NotImplementedException (); } - [MonoTODO] + [MonoTODO] public void Remove(DataRow row) { throw new NotImplementedException (); } - [MonoTODO] - public void RemoveAt(int index) { - throw new NotImplementedException (); - } - - [MonoTODO] - protected override ArrayList List { - [MonoTODO] - get { - return rows; - } + [MonoTODO] + public void RemoveAt(int index) { + throw new NotImplementedException (); + } + + [MonoTODO] + protected override ArrayList List { + [MonoTODO] + get { + return rows; + } } } } diff --git a/mcs/class/System.Data/System.Data/DataTable.cs b/mcs/class/System.Data/System.Data/DataTable.cs index 026c00c79c9..526895be2f8 100644 --- a/mcs/class/System.Data/System.Data/DataTable.cs +++ b/mcs/class/System.Data/System.Data/DataTable.cs @@ -22,8 +22,8 @@ namespace System.Data /// Represents one table of in-memory data. /// [Serializable] - public class DataTable : ISerializable - /* MarshalByValueComponent, IListSource, ISupportInitialize,*/ + public class DataTable : ISerializable + //MarshalByValueComponent, IListSource, ISupportInitialize { private bool _caseSensitive; @@ -91,45 +91,17 @@ namespace System.Data /// Intitalizes a new instance of the DataTable class with the specified table name. /// - public DataTable(string tableName) + public DataTable(string tableName) : this () { - // _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) + protected DataTable(SerializationInfo info, StreamingContext context) + : this () { // // TODO: Add constructor logic here @@ -142,12 +114,10 @@ namespace System.Data public bool CaseSensitive { - get - { + get { return _caseSensitive; } - set - { + set { _caseSensitive = value; } } @@ -159,8 +129,7 @@ namespace System.Data public DataRelationCollection ChildRelations { - get - { + get { // FIXME: temporarily commented to compile // return (DataRelationCollection)_childRelations; throw new NotImplementedException (); @@ -173,8 +142,7 @@ namespace System.Data public DataColumnCollection Columns { - get - { + get { return _columnCollection; } } @@ -185,8 +153,7 @@ namespace System.Data public ConstraintCollection Constraints { - get - { + get { return _constraintCollection; } } @@ -227,12 +194,10 @@ namespace System.Data public string DisplayExpression { - get - { + get { return _displayExpression; } - set - { + set { _displayExpression = value; } } @@ -242,8 +207,7 @@ namespace System.Data /// public PropertyCollection ExtendedProperties { - get - { + get { return _extendedProperties; } } @@ -255,8 +219,7 @@ namespace System.Data /// public bool HasErrors { - get - { + get { return _hasErrors; } } @@ -267,12 +230,10 @@ namespace System.Data /// public CultureInfo Locale { - get - { + get { return _locale; } - set - { + set { _locale = value; } } @@ -282,12 +243,10 @@ namespace System.Data /// public int MinimumCapacity { - get - { + get { return _minimumCapacity; } - set - { + set { _minimumCapacity = value; } } @@ -298,12 +257,10 @@ namespace System.Data /// public string Namespace { - get - { + get { return _nameSpace; } - set - { + set { _nameSpace = value; } } @@ -314,8 +271,7 @@ namespace System.Data /// public DataRelationCollection ParentRelations { - get - { + get { // FIXME: temporarily commented to compile // return _parentRelations; throw new NotImplementedException (); @@ -328,12 +284,10 @@ namespace System.Data /// public string Prefix { - get - { + get { return _prefix; } - set - { + set { _prefix = value; } } @@ -344,12 +298,10 @@ namespace System.Data /// public DataColumn[] PrimaryKey { - get - { + get { return _primaryKey; } - set - { + set { _primaryKey = value; } } @@ -360,8 +312,7 @@ namespace System.Data public DataRowCollection Rows { - get - { + get { return _rows; } } @@ -373,12 +324,10 @@ namespace System.Data public virtual ISite Site { - get - { + get { return _site; } - set - { + set { _site = value; } } @@ -389,12 +338,10 @@ namespace System.Data public string TableName { - get - { + get { return _tableName; } - set - { + set { _tableName = value; } } @@ -402,8 +349,7 @@ namespace System.Data /* FIXME: implement IListSource public bool IListSource.ContainsListCollection { - get - { + get { return _containsListCollection; } } @@ -443,6 +389,7 @@ namespace System.Data public void Clear() { + _rows.Clear (); } /// @@ -520,10 +467,10 @@ namespace System.Data /// Gets an array of DataRow objects that contain errors. /// - //public DataRow[] GetErrors() - //{ - // return _rows; - //} + public DataRow[] GetErrors() + { + throw new NotImplementedException (); + } /// /// This member supports the .NET Framework infrastructure @@ -580,8 +527,8 @@ namespace System.Data /// public DataRow NewRow() { - DataRow dataRow = new DataRow(); - dataRow.SetTable(this); + DataRow dataRow = new DataRow (); + dataRow.SetTable (this); return dataRow; } -- 2.25.1