Beispiel #1
0
        public TaskResult PerformTask <T>(TaskBase <T> task, T argument, object ownerKey = null)
        {
            if (!this.Enable || this.IsUndoing)
            {
                return(TaskResult.NoEnable);
            }
            ArgumentValidator.AssertNotNull <TaskBase <T> >(task, "task");
            if (ownerKey == null)
            {
                return(this.PerformTask <T>(task, argument));
            }
            CancellableTaskServiceEventArgs e = new CancellableTaskServiceEventArgs((ITask)task);

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

            this.TrimIfRequired(ownerKey);
            this.OnExecuted(new TaskServiceEventArgs((ITask)task));
            return(taskResult);
        }
Beispiel #2
0
        private TaskResult PerformTask <T>(TaskBase <T> task, T argument)
        {
            CancellableTaskServiceEventArgs e = new CancellableTaskServiceEventArgs((ITask)task);

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

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