AjScript.Commands.IfCommand.Execute C# (CSharp) Method

Execute() public method

public Execute ( IContext context ) : void
context IContext
return void
        public void Execute(IContext context)
        {
            object result = this.condition.Evaluate(context);

            if (Predicates.IsTrue(result))
                this.thenCommand.Execute(context);
            else if (this.elseCommand != null)
                this.elseCommand.Execute(context);
        }

Usage Example

Beispiel #1
0
        public void ExecuteIfCommandWhenTrue()
        {
            IExpression condition = new ConstantExpression(true);
            ICommand setCommand = new SetVariableCommand("a", new ConstantExpression(1));
            IfCommand command = new IfCommand(condition, setCommand);

            Context context = new Context();

            command.Execute(context);

            Assert.AreEqual(1, context.GetValue("a"));
        }
All Usage Examples Of AjScript.Commands.IfCommand::Execute