コード例 #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
ファイル: TransactionalCommand.cs プロジェクト: Gope/Apollo
 /// <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
ファイル: TransactionalCommand.cs プロジェクト: Gope/Apollo
 /// <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
ファイル: CommandManager.cs プロジェクト: Gope/Apollo
        /// <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
ファイル: CommandManager.cs プロジェクト: Gope/Apollo
        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();
            }
        }