Пример #1
0
        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);
        }
Пример #2
0
        public void AddPropertyMemento(PropertyMemento memento)
        {
            if (memento == null)
            {
                throw new ArgumentNullException();
            }

            CheckAndCreateDictionary();

            _propertyMementoDic[memento.PropertyName] = memento;
        }
Пример #3
0
        public void SetPropertyNewValue(string propertyName, object value)
        {
            CheckAndCreateDictionary();

            PropertyMemento memento = null;

            if (_propertyMementoDic.TryGetValue(propertyName, out memento))
            {
                if (memento != null)
                {
                    memento.NewValue = value;
                }
            }
        }
Пример #4
0
        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);
        }
Пример #5
0
 public PropertyChangeCommand(object target, PropertyMemento memento)
 {
     _target   = target;
     _mementos = new PropertyMementos();
     _mementos.AddPropertyMemento(memento);
 }