public PropertyChangeCommand(object target, string propertyName, object oldValue, object newValue) { _target = target; _mementos = new PropertyMementos(); PropertyMemento memento = new PropertyMemento(propertyName, oldValue, newValue); _mementos.AddPropertyMemento(memento); }
public void AddPropertyMemento(PropertyMemento memento) { if (memento == null) { throw new ArgumentNullException(); } CheckAndCreateDictionary(); _propertyMementoDic[memento.PropertyName] = memento; }
public void SetPropertyNewValue(string propertyName, object value) { CheckAndCreateDictionary(); PropertyMemento memento = null; if (_propertyMementoDic.TryGetValue(propertyName, out memento)) { if (memento != null) { memento.NewValue = value; } } }
public object GetPropertyOldValue(string propertyName) { if (_propertyMementoDic == null) { return(null); } PropertyMemento memento = null; if (_propertyMementoDic.TryGetValue(propertyName, out memento)) { if (memento != null) { return(memento.OldValue); } } return(null); }
public PropertyChangeCommand(object target, PropertyMemento memento) { _target = target; _mementos = new PropertyMementos(); _mementos.AddPropertyMemento(memento); }