public void Redo()
        {
            if (_changes.Count == 0)
            {
                throw new ArgumentException("Cannot redo before any changes are tracked.");
            }
            if (_changes.Count > 0 && _lastChange != null && _lastChange.Equals(_changes.Last()))
            {
                throw new ArgumentException("Cannot redo before any changes are undone.");
            }

            Redo(_changes[_changes.IndexOf(_lastChange) + 1]);
        }
 private PropertyChange MoveLastChange(PropertyChange lastChange)
 {
     if (lastChange.Equals(_changes.First()))
     {
         _lastChange = null;
     }
     else
     {
         _lastChange = _changes[_changes.IndexOf(lastChange) - 1];
     }
     return(_lastChange);
 }
        private PropertyChange Redo(IDbEntity e, PropertyChange lastChange)
        {
            if (!lastChange.IsOrphan(e) ||
                (lastChange.IsDbEntityEnumerable && lastChange.After != null && lastChange.Before == null))
            {
                lastChange.Apply(e);
            }
            _lastChange = lastChange;
            PropertyChange nextChange = null;

            if (!_lastChange.Equals(_changes.Last()))
            {
                nextChange = _changes[_changes.IndexOf(_lastChange) + 1];
            }
            return(nextChange);
        }