Esempio n. 1
0
 static EditOperation TransformForTargetState(EditOperation transformee, IEnumerable<int> sortedTargetState, Dictionary<int, EditOperation> transformedOperations, ICollection<EditOperation> allOperations)
 {
     EditOperation result;
     if (!transformedOperations.TryGetValue(transformee.Id, out result))
     {
         SpringboardState springBoardState = transformee.ChangeSubset.SpringboardState;
         List<int> sortedSpringBoard = new List<int>(springBoardState.Entries.Select(x => x.EditOperationId));
         sortedSpringBoard.Sort();
         List<UndoRedoEntry> undosRedos = new List<UndoRedoEntry>();
         ComputeStateDifferences(transformee.Id, sortedSpringBoard, sortedTargetState, undosRedos);
         result = transformee;
         foreach (UndoRedoEntry undoRedoEntry in undosRedos)
         {
             int transformerId = undoRedoEntry.OperationId;
             EditOperation transformer = TransformForTargetState(allOperations.First(x => (x.Id == transformerId)), sortedTargetState, transformedOperations, allOperations);
             if (undoRedoEntry.IsRedo)
                 result = result.RedoPrior(transformer);
             else
                 result = result.UndoPrior(transformer);
         }
         transformedOperations[transformee.Id] = result;
     }
     return result;
 }