AjScript.Commands.CompositeCommand.Execute C# (CSharp) Метод

Execute() публичный Метод

public Execute ( IContext context ) : void
context IContext
Результат void
        public virtual void Execute(IContext context)
        {
            if (this.hoistedCommands != null)
                foreach (ICommand command in this.hoistedCommands)
                    command.Execute(context);

            foreach (ICommand command in this.commands)
            {
                command.Execute(context);

                if (context.ReturnValue != null)
                    return;
            }
        }

Usage Example

Пример #1
0
        public void ExecuteCompositeCommand()
        {
            Context context = new Context();

            SetVariableCommand command1 = new SetVariableCommand("a", new ConstantExpression("bar"));
            SetVariableCommand command2 = new SetVariableCommand("b", new ConstantExpression(1));
            SetVariableCommand command3 = new SetVariableCommand("c", new VariableExpression("a"));

            List<ICommand> commands = new List<ICommand>();
            commands.Add(command1);
            commands.Add(command2);
            commands.Add(command3);

            CompositeCommand command = new CompositeCommand(commands);

            command.Execute(context);

            Assert.AreEqual("bar", context.GetValue("a"));
            Assert.AreEqual(1, context.GetValue("b"));
            Assert.AreEqual("bar", context.GetValue("c"));
        }