private void OnRowElementInsertedInTree(XmlBoundElement rowElem, ArrayList rowElemList)
{
Debug.Assert(rowElem.Row != null);
DataRow row = rowElem.Row;
DataRowState rowState = row.RowState;
switch (rowState)
{
case DataRowState.Detached:
#if DEBUG
try
{
Debug.Assert(row.Table.DataSet.EnforceConstraints == false);
#endif
row.Table.Rows.Add(row);
SetNestedParentRegion(rowElem);
#if DEBUG
}
catch
{
// We should not get any exceptions here
Debug.Assert(false);
throw;
}
#endif
// Add all sub-regions to the list if the caller needs this
if (rowElemList != null)
{
RegionIterator iter = new RegionIterator(rowElem);
for (bool fMore = iter.NextRowElement(); fMore; fMore = iter.NextRightRowElement())
rowElemList.Add(iter.CurrentNode);
}
break;
case DataRowState.Deleted:
#if DEBUG
try
{
Debug.Assert(row.Table.DataSet.EnforceConstraints == false);
#endif
// Change the row status to be alive (unchanged)
row.RejectChanges();
// Set ROM from XML
SynchronizeRowFromRowElement(rowElem, rowElemList);
// Set nested parent data row according to where is the row positioned in the tree
SetNestedParentRegion(rowElem);
#if DEBUG
}
catch
{
// We should not get any exceptions here
Debug.Assert(false);
throw;
}
#endif
break;
default:
// Handle your case above
Debug.Assert(false);
break;
}
Debug.Assert(IsRowLive(rowElem.Row));
}