Exemple #1
0
        protected override void ExecuteStatement(ExecutionContext context)
        {
            var resultType = ConditionExpression.ReturnType(context.Request, null);

            if (!(resultType is BooleanType))
            {
                throw new StatementException("The condition expression does not evaluate to a boolean.");
            }

            // The condition statement triggers the creation of a new context

            var block = context.NewBlock(this);

            var conditionResult = ConditionExpression.EvaluateToConstant(context.Request, null);

            if (conditionResult)
            {
                foreach (var statement in TrueStatements)
                {
                    statement.Execute(block);

                    if (block.HasTermination)
                    {
                        break;
                    }
                }
            }
            else if (FalseStatements != null)
            {
                foreach (var statement in FalseStatements)
                {
                    statement.Execute(block);

                    if (block.HasTermination)
                    {
                        break;
                    }
                }
            }
        }