Exemplo n.º 1
0
 private int GetHashCode(UndoablePropertyChange undoablePropertyChange)
 {
     unchecked
     {
         return(undoablePropertyChange.ModelObject.GetHashCode() + undoablePropertyChange.PropertyDescriptor.Name.GetHashCode());
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Adds the specified IUndoable to this UndoableGroup.
        /// </summary>
        /// <param name="undoable">The IUndoable to add to this UndoableGroup.</param>
        protected override void AddUndoable(IUndoable undoable)
        {
            UndoablePropertyChange currentUndoablePropertyChange = (UndoablePropertyChange)undoable;
            int hashCode = this.GetHashCode(currentUndoablePropertyChange);

            this.Reset();

            UndoablePropertyChange rootUndoablePropertyChange;

            if (!this.rootUndoablePropertyChanges.TryGetValue(hashCode, out rootUndoablePropertyChange))
            {
                rootUndoablePropertyChange = currentUndoablePropertyChange;
                this.rootUndoablePropertyChanges.Add(hashCode, currentUndoablePropertyChange);
            }

            this.rootUndoablePropertyChanges[hashCode] = new UndoablePropertyChange(
                rootUndoablePropertyChange.ModelObject,
                rootUndoablePropertyChange.PropertyDescriptor.Name,
                rootUndoablePropertyChange.OldValue,
                currentUndoablePropertyChange.NewValue);

            foreach (UndoablePropertyChange undoablePropertyChange in this.rootUndoablePropertyChanges.Values)
            {
                base.AddUndoable(undoablePropertyChange);
            }
        }