private void SynchronizeRowFromRowElementEx(XmlBoundElement rowElement, ArrayList rowElemList)
{
Debug.Assert(rowElement != null);
Debug.Assert(rowElement.Row != null);
Debug.Assert(DataSet.EnforceConstraints == false);
DataRow row = rowElement.Row;
Debug.Assert(row != null);
DataTable table = row.Table;
Hashtable foundColumns = new Hashtable();
string xsi_attrVal = string.Empty;
RegionIterator iter = new RegionIterator(rowElement);
bool fMore;
// If present, fill up the TextOnly column
DataColumn column = GetTextOnlyColumn(row);
if (column != null)
{
foundColumns[column] = column;
string value;
fMore = iter.NextInitialTextLikeNodes(out value);
if (value.Length == 0 && (((xsi_attrVal = rowElement.GetAttribute(XSI_NIL)) == "1") || xsi_attrVal == "true"))
row[column] = DBNull.Value;
else
SetRowValueFromXmlText(row, column, value);
}
else
fMore = iter.Next();
// Fill up the columns mapped to an element
while (fMore)
{
XmlElement e = iter.CurrentNode as XmlElement;
if (e == null)
{
fMore = iter.Next();
continue;
}
XmlBoundElement be = e as XmlBoundElement;
if (be != null && be.Row != null)
{
if (rowElemList != null)
rowElemList.Add(e);
// Skip over sub-regions
fMore = iter.NextRight();
continue;
}
DataColumn c = _mapper.GetColumnSchemaForNode(rowElement, e);
if (c != null)
{
Debug.Assert(c.Table == row.Table);
if (foundColumns[c] == null)
{
foundColumns[c] = c;
string value;
fMore = iter.NextInitialTextLikeNodes(out value);
if (value.Length == 0 && (((xsi_attrVal = e.GetAttribute(XSI_NIL)) == "1") || xsi_attrVal == "true"))
row[c] = DBNull.Value;
else
SetRowValueFromXmlText(row, c, value);
continue;
}
}
fMore = iter.Next();
}
//
// Walk the attributes to find attributes that map to columns.
//
foreach (XmlAttribute attr in rowElement.Attributes)
{
DataColumn c = _mapper.GetColumnSchemaForNode(rowElement, attr);
if (c != null)
{
if (foundColumns[c] == null)
{
foundColumns[c] = c;
SetRowValueFromXmlText(row, c, attr.Value);
}
}
}
// Null all columns values that aren't represented in the tree
foreach (DataColumn c in row.Table.Columns)
{
if (foundColumns[c] == null && !IsNotMapped(c))
{
if (!c.AutoIncrement)
SetRowValueToNull(row, c);
else
c.Init(row._tempRecord);
}
}
}