Exemple #1
0
        public override void Exit()
        {
            StatementSyntax statement;

            if (_hookName == null)
            {
                statement = SF.Block();
            }
            else
            {
                statement = BlockContext.MakeWriteStatement(MethodCallContext.CreateMethodCall(_hookName, true));
            }
            ExpressionSyntax condition;

            if (_valueExpression == null)
            {
                condition = _testExpression;
            }
            else
            {
                condition = SF.BinaryExpression(SyntaxKind.EqualsExpression, _testExpression, _valueExpression);
            }
            var whenStatement = SF.IfStatement(condition, statement);

            _exitHandler(whenStatement);
        }
Exemple #2
0
        public override void Exit()
        {
            StatementSyntax statement;

            if (_hookName == null)
            {
                statement = SF.Block();
            }
            else
            {
                statement = BlockContext.MakeWriteStatement(MethodCallContext.CreateMethodCall(_hookName, true));
            }
            var ifStatement = SF.IfStatement(_condition, statement, _elseClause);

            _exitHandler(ifStatement);
        }
Exemple #3
0
        public override ICodeContext CreateContext(CodeContextTypes contextType, string name = null, Bag <string> attributes = null)
        {
            switch (contextType)
            {
            case CodeContextTypes.Argument:
                return(new ExpressionContext((expression) =>
                {
                    if (expression == null)
                    {
                        _valueExpression = SF.LiteralExpression(SyntaxKind.TrueKeyword);
                    }
                    else
                    {
                        _valueExpression = expression.ToExpression();
                    }
                }));

            case CodeContextTypes.When:
                return(new WhenContext(name, _valueExpression, (whenStatement) =>
                {
                    _whenClauses.Add(whenStatement);
                }));

            case CodeContextTypes.Otherwise:
                string elseHookName = name;
                return(new BlockContext((block) =>
                {
                    if (elseHookName == null)
                    {
                        _otherwiseClause = SF.ElseClause(block);
                    }
                    else
                    {
                        _otherwiseClause = SF.ElseClause(BlockContext.MakeWriteStatement(MethodCallContext.CreateMethodCall(elseHookName, true)));
                    }
                }));
            }
            return(base.CreateContext(contextType, name, attributes));
        }
Exemple #4
0
        public override void Exit()
        {
            List <StatementSyntax> loopStatements = new List <StatementSyntax>();

            //loopStatements.Add(StateHelper.MakeStatePushStatement());
            loopStatements.Add(SF.ExpressionStatement(
                                   SF.AssignmentExpression(
                                       SyntaxKind.SimpleAssignmentExpression,
                                       VariableHelper.MakeStateVariableExpression(_asVariableName),
                                       SF.IdentifierName(_iteratorVariableName)
                                       )
                                   )
                               );
            if (_hookName != null)
            {
                loopStatements.Add(BlockContext.MakeWriteStatement(MethodCallContext.CreateMethodCall(_hookName, true)));
            }
            //loopStatements.Add(StateHelper.MakeStatePopWriteStatement());
            var forEachStatement = SF.ForEachStatement(SF.ParseTypeName("var"), _iteratorVariableName, _expression, SF.Block(loopStatements));

            _exitHandler(forEachStatement);
        }
Exemple #5
0
        public override ICodeContext CreateContext(CodeContextTypes contextType, string name = null, Bag <string> attributes = null)
        {
            switch (contextType)
            {
            case CodeContextTypes.Argument:
                return(new ExpressionContext((expression) =>
                {
                    if (expression == null)
                    {
                        _condition = SF.LiteralExpression(SyntaxKind.FalseKeyword);
                    }
                    else
                    {
                        _condition = expression.ToExpression();
                    }
                }));

            case CodeContextTypes.ElseIf:
                return(new IfContext(name, (ifStatement) =>
                {
                    _elseClause = SF.ElseClause(ifStatement);
                }));

            case CodeContextTypes.Else:
                string elseHookName = name;
                return(new BlockContext((block) =>
                {
                    if (elseHookName == null)
                    {
                        _elseClause = SF.ElseClause(block);
                    }
                    else
                    {
                        _elseClause = SF.ElseClause(BlockContext.MakeWriteStatement(MethodCallContext.CreateMethodCall(elseHookName, true)));
                    }
                }));
            }
            return(base.CreateContext(contextType, name, attributes));
        }