예제 #1
0
        /// <summary>
        /// Unexecutes the command in a spawned thread.
        /// </summary>
        /// <param name="command">The command.</param>
        private void UnExecuteInSpawnedThread(AbstractCommand command)
        {
            command.CancellationTokenSource = new CancellationTokenSource();

            Task.Factory
            .StartNew(command.UnExecute);
        }
예제 #2
0
        public void RecordCommand(AbstractCommand command)
        {
            if (command == null)
            {
                throw new ArgumentException("Command needs to be of type AbstractCommand", "command");
            }

            if (unboundedTransactionRunning && !unboundedTransactionCall)
            {
                throw new InvalidOperationException("An unbound transaction is currently running. Before executing a regular command you need to either commit or rollback the " +
                                                    "current transaction. Also you can add more commands to the current transaction via CommandManager.RunWithinTransaction().");
            }

            if (CurrentTransaction == null)
            {
                CurrentTransaction = new TransactionalCommand();
                this.UndoStack.Push(CurrentTransaction);
            }

            CurrentTransaction.AddCommand(command);

            if (command.ExecutionConfiguration.RunInBackground)
            {
                this.ExecuteInSpawnedThread(command);
            }
            else
            {
                command.Execute();
            }
        }
예제 #3
0
 /// <summary>
 /// Adds a new command to the internal collection.
 /// </summary>
 /// <param name="command">The command.</param>
 public void AddCommand(AbstractCommand command)
 {
     this.Commands.Add(command);
 }
예제 #4
0
 /// <summary>
 /// Adds a new command to the internal collection.
 /// </summary>
 /// <param name="command">The command.</param>
 public void AddCommand(AbstractCommand command)
 {
     this.Commands.Add(command);
 }
예제 #5
0
        /// <summary>
        /// Unexecutes the command in a spawned thread.
        /// </summary>
        /// <param name="command">The command.</param>
        private void UnExecuteInSpawnedThread(AbstractCommand command)
        {
            command.CancellationTokenSource = new CancellationTokenSource();

            Task.Factory
                .StartNew(command.UnExecute);
        }
예제 #6
0
        public void RecordCommand(AbstractCommand command)
        {
            if (command == null)
            {
                throw new ArgumentException("Command needs to be of type AbstractCommand", "command");
            }

            if (unboundedTransactionRunning && !unboundedTransactionCall)
            {
                throw new InvalidOperationException("An unbound transaction is currently running. Before executing a regular command you need to either commit or rollback the " +
                                                     "current transaction. Also you can add more commands to the current transaction via CommandManager.RunWithinTransaction().");
            }

            if (CurrentTransaction == null)
            {
                CurrentTransaction = new TransactionalCommand();
                this.UndoStack.Push(CurrentTransaction);
            }

            CurrentTransaction.AddCommand(command);

            if (command.ExecutionConfiguration.RunInBackground)
            {
                this.ExecuteInSpawnedThread(command);
            }
            else
            {
                command.Execute();
            }
        }