System.Data.DataTableReader.DataChanged C# (CSharp) Méthode

DataChanged() private méthode

private DataChanged ( DataRowChangeEventArgs args ) : void
args DataRowChangeEventArgs
Résultat void
        internal void DataChanged(DataRowChangeEventArgs args)
        {
            if ((!_started) || (_rowCounter == -1 && !_tableCleared))
            {
                return;
            }

            switch (args.Action)
            {
                case DataRowAction.Add:
                    ValidateRow(_rowCounter + 1);
                    if (_currentDataRow == _currentDataTable.Rows[_rowCounter + 1])
                    {
                        // check if we moved one position up
                        _rowCounter++;  // if so, refresh the datarow and fix the counter
                    }
                    break;
                case DataRowAction.Delete: // delete
                case DataRowAction.Rollback:// rejectchanges
                case DataRowAction.Commit: // acceptchanges
                    if (args.Row.RowState == DataRowState.Detached)
                    {
                        if (args.Row != _currentDataRow)
                        {
                            if (_rowCounter == 0) // if I am at first row and no previous row exist,NOOP
                                break;
                            ValidateRow(_rowCounter - 1);
                            if (_currentDataRow == _currentDataTable.Rows[_rowCounter - 1])
                            {
                                // one of previous rows is detached, collection size is changed!
                                _rowCounter--;
                            }
                        }
                        else
                        { // we are proccessing current datarow
                            _currentRowRemoved = true;
                            if (_rowCounter > 0)
                            {
                                // go back one row, no matter what the state is
                                _rowCounter--;
                                _currentDataRow = _currentDataTable.Rows[_rowCounter];
                            }
                            else
                            {
                                // we are on 0th row, so reset data to initial state!
                                _rowCounter = -1;
                                _currentDataRow = null;
                            }
                        }
                    }
                    break;
                default:
                    break;
            }
        }
    }

Usage Example

Exemple #1
0
        private void DataChanged(object sender, DataRowChangeEventArgs args)
        {
            DataTableReader reader = (DataTableReader)_readerWeak.Target;

            if (reader != null)
            {
                reader.DataChanged(args);
            }
            else
            {
                UnSubscribeEvents();
            }
        }
All Usage Examples Of System.Data.DataTableReader::DataChanged