void IColumnChangingObserver.Handle(DemoDataRow row, ColumnChangedArgs columnChangedArgs) { if(ContainsInvalidCharacters(columnChangedArgs.NewValue)) { Console.WriteLine("The newValue {0} has invalid characters changed rejected", columnChangedArgs.NewValue); columnChangedArgs.CancelEvent = true; } }
protected bool PublishChangingEvent( string columnName, string oldValue, string newValue) { bool cancelled = false; for(int i = 0; i < _changingObservers.Count; i++) { ColumnChangedArgs columnChangedArgs = new ColumnChangedArgs { CancelEvent = false, ColumnName = columnName, NewValue = newValue, OldValue = oldValue }; _changingObservers[i].Handle(this, columnChangedArgs); if(columnChangedArgs.CancelEvent) { cancelled = true; } } return cancelled; }
protected void PublishChangedEvent(string columnName, string oldValue, string newValue) { for (int i = 0; i < _changedObservers.Count; i++) { ColumnChangedArgs columnChangedArgs = new ColumnChangedArgs { CancelEvent = false, ColumnName = columnName, NewValue = newValue, OldValue = oldValue }; _changedObservers[i].Handle(this, columnChangedArgs); } }
void OnColumnDeleted(DemoDataRow row, ColumnChangedArgs columnChangedArgs) { Console.WriteLine("The following column: {0} with the value: {1} was deleted.", columnChangedArgs.ColumnName, columnChangedArgs.OldValue); }
void IColumnChangedObserver.Handle(DemoDataRow row, ColumnChangedArgs columnChangedArgs) { Console.WriteLine("Data was changed as follows: Column Name: {0} Changed From: {1} To: {2}", columnChangedArgs.ColumnName, columnChangedArgs.OldValue, columnChangedArgs.NewValue); }