コード例 #1
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();
            }
        }
コード例 #2
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();
            }
        }