2003-11-09 Pedro Mart�nez Juli� <yoros@wanadoo.es>
authorPedro Martínez Juliá <pedro@mono-cvs.ximian.com>
Sun, 9 Nov 2003 18:51:03 +0000 (18:51 -0000)
committerPedro Martínez Juliá <pedro@mono-cvs.ximian.com>
Sun, 9 Nov 2003 18:51:03 +0000 (18:51 -0000)
    * DataRow.cs: Use RemoveInternal instead of Remove because the last
    one uses Delete and AcceptChanges.

    * DataRowCollection.cs: When removing, Delete and AcceptChanges
    method from the row are called. Added an internal method that will
    be used by DataRow to "physically" remove the row from the list.

svn path=/trunk/mcs/; revision=19768

mcs/class/System.Data/System.Data/ChangeLog
mcs/class/System.Data/System.Data/DataRow.cs
mcs/class/System.Data/System.Data/DataRowCollection.cs

index 42a415dd6f4bea049704c26494e4174b3502107d..bd0d0fee1b6bcde971789af6a8ea1e432f867bec 100644 (file)
@@ -1,3 +1,12 @@
+2003-11-09  Pedro Martínez Juliá  <yoros@wanadoo.es>
+
+       * DataRow.cs: Use RemoveInternal instead of Remove because the last
+       one uses Delete and AcceptChanges.
+
+       * DataRowCollection.cs: When removing, Delete and AcceptChanges
+       method from the row are called. Added an internal method that will
+       be used by DataRow to "physically" remove the row from the list.
+
 2003-11-09  Pedro Martínez Juliá  <yoros@wanadoo.es>
 
        * DataRowCollection.cs: To follow the specification: Remove and
index 754ac6820697e51663f39aa8abeb3526eebb17c8..55c41b9c97d3c9da82209f79bff1b10faad1e69d 100644 (file)
@@ -435,7 +435,7 @@ namespace System.Data {
                                rowState = DataRowState.Unchanged;
                                break;
                        case DataRowState.Deleted:
-                               _table.Rows.Remove (this);
+                               _table.Rows.RemoveInternal (this);
                                break;
                        case DataRowState.Detached:
                                throw new RowNotInTableException("Cannot perform this operation on a row not in the table.");
@@ -493,20 +493,20 @@ namespace System.Data {
                [MonoTODO]
                public void Delete () 
                {
+                       _table.DeletingDataRow(this, DataRowAction.Delete);
                        switch (rowState) {
                        case DataRowState.Added:
-                               Table.Rows.Remove (this);
+                               Table.Rows.RemoveInternal (this);
                                break;
                        case DataRowState.Deleted:
                                throw new DeletedRowInaccessibleException ();
                        default:
-                               _table.DeletingDataRow(this, DataRowAction.Delete);
                                // check what to do with child rows
                                CheckChildRows(DataRowAction.Delete);
                                rowState = DataRowState.Deleted;
-                               _table.DeletedDataRow(this, DataRowAction.Delete);
                                break;
                        }
+                       _table.DeletedDataRow(this, DataRowAction.Delete);
                }
 
                // check the child rows of this row before deleting the row.
@@ -973,7 +973,7 @@ namespace System.Data {
                                switch (rowState)
                                {
                                        case DataRowState.Added:
-                                               _table.Rows.Remove (this);
+                                               _table.Rows.RemoveInternal (this);
                                                break;
                                        case DataRowState.Modified:
                                                rowState = DataRowState.Unchanged;
@@ -991,7 +991,7 @@ namespace System.Data {
                                // if so: FIXME ;)
                                
                                if ((rowState & DataRowState.Added) > 0)
-                                       _table.Rows.Remove (this);
+                                       _table.Rows.RemoveInternal (this);
                        }
                }
 
index dd7eebe611fd1e31e383584354c664a86e6ab1fb..5081691e909724e59ff75592b3f77634ca98cd65 100644 (file)
@@ -241,6 +241,20 @@ namespace System.Data
                                list.Insert (pos, row);
                }
 
+               /// <summary>
+               /// Removes the specified DataRow from the internal list. Used by DataRow to commit the removing.
+               /// </summary>
+               internal void RemoveInternal (DataRow row) {
+                       if (row == null) {
+                               throw new IndexOutOfRangeException ("The given datarow is not in the current DataRowCollection.");
+                       }
+                       int index = list.IndexOf(row);
+                       if (index < 0) {
+                               throw new IndexOutOfRangeException ("The given datarow is not in the current DataRowCollection.");
+                       }
+                       list.RemoveAt(index);
+               }
+
                /// <summary>
                /// Removes the specified DataRow from the collection.
                /// </summary>
@@ -251,9 +265,8 @@ namespace System.Data
                        int index = list.IndexOf(row);
                        if (index < 0)
                                throw new IndexOutOfRangeException ("The given datarow is not in the current DataRowCollection.");
-                       table.DeletingDataRow(row, DataRowAction.Delete);
-                       list.RemoveAt(index);
-                       table.DeletedDataRow(row, DataRowAction.Delete);
+                       row.Delete();
+                       row.AcceptChanges();
                }
 
                /// <summary>
@@ -264,9 +277,8 @@ namespace System.Data
                        if (index < 0 || index >= list.Count)
                                throw new IndexOutOfRangeException ("There is no row at position " + index + ".");
                        DataRow row = (DataRow)list [index];
-                       table.DeletingDataRow(row, DataRowAction.Delete);
-                       list.RemoveAt(index);
-                       table.DeletedDataRow(row, DataRowAction.Delete);
+                       row.Delete();
+                       row.AcceptChanges();
                }
 
                ///<summary>