private void CheckPopUnit(PopUnitReason reason)
 {
     if ((reason != PopUnitReason.Normal) || !this._host.InTransaction)
     {
         UndoUnit unit = (UndoUnit)this._unitStack.Pop();
         if (!unit.IsEmpty)
         {
             unit.Close();
             if (reason != PopUnitReason.TransactionCancel)
             {
                 if (this._unitStack.Count == 0)
                 {
                     this.AddUndoUnit(unit);
                 }
             }
             else
             {
                 unit.Undo();
                 if (this._unitStack.Count == 0)
                 {
                     this.DiscardUndoUnit(unit);
                 }
             }
         }
         else if (this._unitStack.Count == 0)
         {
             this.DiscardUndoUnit(unit);
         }
     }
 }
 private void CheckPopUnit(PopUnitReason reason)
 {
     if ((reason != PopUnitReason.Normal) || !this._host.InTransaction)
     {
         UndoUnit unit = (UndoUnit) this._unitStack.Pop();
         if (!unit.IsEmpty)
         {
             unit.Close();
             if (reason != PopUnitReason.TransactionCancel)
             {
                 if (this._unitStack.Count == 0)
                 {
                     this.AddUndoUnit(unit);
                 }
             }
             else
             {
                 unit.Undo();
                 if (this._unitStack.Count == 0)
                 {
                     this.DiscardUndoUnit(unit);
                 }
             }
         }
         else if (this._unitStack.Count == 0)
         {
             this.DiscardUndoUnit(unit);
         }
     }
 }
 private void OnTransactionClosed(object sender, DesignerTransactionCloseEventArgs e)
 {
     if ((this._executingUnit == null) && (this.CurrentUnit != null))
     {
         PopUnitReason reason = e.TransactionCommitted ? PopUnitReason.TransactionCommit : PopUnitReason.TransactionCancel;
         this.CheckPopUnit(reason);
     }
 }