Execute() 공개 메소드

public Execute ( Context context ) : object
context Context
리턴 object
예제 #1
0
        public void CreateAndExecuteCompositeCommand()
        {
            IEnumerable<ICommand> commands = new ICommand[] {
                new SetVariableCommand("a", new ConstantExpression(1)),
                new SetVariableCommand("b", new ConstantExpression(2))
            };

            CompositeCommand command = new CompositeCommand(commands);

            Context context = new Context();

            Assert.IsNotNull(command.Commands);
            Assert.AreEqual(2, command.Commands.Count());
            Assert.AreEqual(2, command.Execute(context));
            Assert.AreEqual(1, context.GetValue("a"));
            Assert.AreEqual(2, context.GetValue("b"));
        }
예제 #2
0
        private static void EvaluateCommands(string text, Context context)
        {
            Parser parser = new Parser(text);

            var result = parser.ParseCommands();

            var command = new CompositeCommand(result);
            command.Execute(context);
        }