public void Perform(IOperation operation) { AssertTransaction(); PerformingOperation?.Invoke(operation); operation.TransactionId = transactionId; if (saveIndex > currentIndex) { saveIndex = -1; } if (currentIndex == operations.Count) { operations.Add(operation); currentIndex++; } else if (operation.IsChangingDocument) { operations.RemoveRange(currentIndex, operations.Count - currentIndex); operations.Add(operation); currentIndex = operations.Count; } else { operations.Insert(currentIndex, operation); operations.Insert(currentIndex, operation); currentIndex++; } Processors.Do(operation); OnChange(); }