public static void MoveTo(this IOperationController controller, IOperation target) { var isRollBack = controller.Operations.Contains(target); var isRollForward = controller.RollForwardTargets.Contains(target); if (isRollBack is false && isRollForward is false) { return; } if (isRollBack) { while (controller.Peek() != target) { controller.Undo(); } } if (isRollForward) { while (controller.RollForwardTargets.FirstOrDefault() != target) { controller.Redo(); } controller.Redo(); } }