System.Data.NewDiffgramGen.GenerateRow C# (CSharp) Method

GenerateRow() private method

private GenerateRow ( DataRow row ) : void
row DataRow
return void
        private void GenerateRow(DataRow row)
        {
            DataRowState state = row.RowState;
            if ((state == DataRowState.Unchanged) || (state == DataRowState.Added))
            {
                return;
            }
            if (!_fBefore)
            {
                _xmlw.WriteStartElement(Keywords.DFF, Keywords.SQL_BEFORE, Keywords.DFFNS);
                _fBefore = true;
            }

            DataTable table = row.Table;
            int colCount = table.Columns.Count;
            string rowIDString = table.TableName + row.rowID.ToString(CultureInfo.InvariantCulture);
            string parentId = null;
            if ((state == DataRowState.Deleted) && (row.Table.NestedParentRelations.Length != 0))
            {
                DataRow parentRow = row.GetNestedParentRow(DataRowVersion.Original);
                if (parentRow != null)
                {
                    parentId = parentRow.Table.TableName + parentRow.rowID.ToString(CultureInfo.InvariantCulture);
                }
            }


            string tablePrefix = (table.Namespace.Length != 0) ? table.Prefix : string.Empty;

            // read value if the TextOnly column (if any)
            object val = (table.XmlText == null ? DBNull.Value : row[table.XmlText, DataRowVersion.Original]);

            //old row
            _xmlw.WriteStartElement(tablePrefix, row.Table.EncodedTableName, row.Table.Namespace);

            _xmlw.WriteAttributeString(Keywords.DFF, Keywords.DIFFID, Keywords.DFFNS, rowIDString);

            if ((state == DataRowState.Deleted) && XmlDataTreeWriter.RowHasErrors(row))
                _xmlw.WriteAttributeString(Keywords.DFF, Keywords.HASERRORS, Keywords.DFFNS, Keywords.TRUE);

            if (parentId != null)
                _xmlw.WriteAttributeString(Keywords.DFF, Keywords.DIFFPID, Keywords.DFFNS, parentId);

            _xmlw.WriteAttributeString(Keywords.MSD, Keywords.ROWORDER, Keywords.MSDNS, _rowsOrder[row].ToString());
            for (int colNum = 0; colNum < colCount; ++colNum)
            {
                if ((row.Table.Columns[colNum].ColumnMapping == MappingType.Attribute) ||
                    (row.Table.Columns[colNum].ColumnMapping == MappingType.Hidden))
                    GenerateColumn(row, row.Table.Columns[colNum], DataRowVersion.Original);
            }
            for (int colNum = 0; colNum < colCount; ++colNum)
            {
                if ((row.Table.Columns[colNum].ColumnMapping == MappingType.Element) ||
                    (row.Table.Columns[colNum].ColumnMapping == MappingType.SimpleContent))
                    GenerateColumn(row, row.Table.Columns[colNum], DataRowVersion.Original);
            }
            _xmlw.WriteEndElement();  //old row
        }