예제 #1
0
        private TaskResult PerformTask <T>(UndoableTaskBase <T> task, T argument)
        {
            CancellableTaskServiceEventArgs e = new CancellableTaskServiceEventArgs((ITask)task);

            this.OnExecuting(e);
            if (e.Cancel)
            {
                return(TaskResult.Cancelled);
            }
            this.globallyRedoableTasks.Clear();
            this.globallyRepeatableTasks.AddLast((IInternalTask)task);
            this.globallyUndoableTasks.AddLast((IUndoableTask)task);
            TaskResult taskResult = task.PerformTask((object)argument, TaskMode.FirstTime);

            this.TrimIfRequired((object)null);
            this.OnExecuted(new TaskServiceEventArgs((ITask)task));
            return(taskResult);
        }
예제 #2
0
        public TaskResult PerformTask <T>(UndoableTaskBase <T> task, T argument, object ownerKey = null)
        {
            if (!this.Enable || this.IsUndoing)
            {
                return(TaskResult.NoEnable);
            }
            ArgumentValidator.AssertNotNull <UndoableTaskBase <T> >(task, "task");
            if (ownerKey == null)
            {
                return(this.PerformTask <T>(task, argument));
            }
            CancellableTaskServiceEventArgs e = new CancellableTaskServiceEventArgs((ITask)task)
            {
                OwnerKey = ownerKey
            };

            this.OnExecuting(e);
            if (e.Cancel)
            {
                return(TaskResult.Cancelled);
            }
            this.redoableDictionary.Remove(ownerKey);
            TaskService.TaskCollection <IInternalTask> taskCollection1;
            if (!this.repeatableDictionary.TryGetValue(ownerKey, out taskCollection1))
            {
                taskCollection1 = new TaskService.TaskCollection <IInternalTask>();
                this.repeatableDictionary[ownerKey] = taskCollection1;
            }
            taskCollection1.AddLast((IInternalTask)task);
            TaskService.TaskCollection <IUndoableTask> taskCollection2;
            if (!this.undoableDictionary.TryGetValue(ownerKey, out taskCollection2))
            {
                taskCollection2 = new TaskService.TaskCollection <IUndoableTask>();
                this.undoableDictionary[ownerKey] = taskCollection2;
            }
            taskCollection2.AddLast((IUndoableTask)task);
            TaskResult taskResult = task.PerformTask((object)argument, TaskMode.FirstTime);

            this.TrimIfRequired(ownerKey);
            this.OnExecuted(new TaskServiceEventArgs((ITask)task));
            return(taskResult);
        }