コード例 #1
0
ファイル: Expression.cs プロジェクト: yuzd/Spring.EL
        /// <summary>
        /// Registers lambda expression under the specified <paramref name="functionName"/>.
        /// </summary>
        /// <param name="functionName">Function name to register expression as.</param>
        /// <param name="lambdaExpression">Lambda expression to register.</param>
        /// <param name="variables">Variables dictionary that the function will be registered in.</param>
        public static void RegisterFunction(string functionName, string lambdaExpression, IDictionary variables)
        {
            AssertUtils.ArgumentHasText(functionName, "functionName");
            AssertUtils.ArgumentHasText(lambdaExpression, "lambdaExpression");

            ExpressionLexer  lexer  = new ExpressionLexer(new StringReader(lambdaExpression));
            ExpressionParser parser = new SpringExpressionParser(lexer);

            try
            {
                parser.lambda();
            }
            catch (TokenStreamRecognitionException ex)
            {
                throw new SyntaxErrorException(ex.recog.Message, ex.recog.getLine(), ex.recog.getColumn(), lambdaExpression);
            }
            variables[functionName] = parser.getAST();
        }
コード例 #2
0
ファイル: Expression.cs プロジェクト: yuzd/Spring.EL
        /// <summary>
        /// Initializes a new instance of the <see cref="Expression"/> class
        /// by parsing specified property expression string.
        /// </summary>
        /// <param name="expression">Property expression to parse.</param>
        internal static IExpression ParseProperty(string expression)
        {
            if (StringUtils.HasText(expression))
            {
                ExpressionLexer  lexer  = new ExpressionLexer(new StringReader(expression));
                ExpressionParser parser = new SpringExpressionParser(lexer);

                try
                {
                    parser.property();
                }
                catch (TokenStreamRecognitionException ex)
                {
                    throw new SyntaxErrorException(ex.recog.Message, ex.recog.getLine(), ex.recog.getColumn(), expression);
                }
                return((IExpression)parser.getAST());
            }
            else
            {
                return(new Expression());
            }
        }
コード例 #3
0
ファイル: Expression.cs プロジェクト: likesea/spring.net
        /// <summary>
        /// Initializes a new instance of the <see cref="Expression"/> class
        /// by parsing specified property expression string.
        /// </summary>
        /// <param name="expression">Property expression to parse.</param>
        internal static IExpression ParseProperty( string expression )
        {
            if (StringUtils.HasText( expression ))
            {
                ExpressionLexer lexer = new ExpressionLexer( new StringReader( expression ) );
                ExpressionParser parser = new SpringExpressionParser( lexer );

                try
                {
                    parser.property();
                }
                catch (TokenStreamRecognitionException ex)
                {
                    throw new SyntaxErrorException( ex.recog.Message, ex.recog.getLine(), ex.recog.getColumn(), expression );
                }
                return (IExpression)parser.getAST();
            }
            else
            {
                return new Expression();
            }
        }
コード例 #4
0
ファイル: Expression.cs プロジェクト: likesea/spring.net
        /// <summary>
        /// Registers lambda expression under the specified <paramref name="functionName"/>.
        /// </summary>
        /// <param name="functionName">Function name to register expression as.</param>
        /// <param name="lambdaExpression">Lambda expression to register.</param>
        /// <param name="variables">Variables dictionary that the function will be registered in.</param>
        public static void RegisterFunction( string functionName, string lambdaExpression, IDictionary variables )
        {
            AssertUtils.ArgumentHasText( functionName, "functionName" );
            AssertUtils.ArgumentHasText( lambdaExpression, "lambdaExpression" );

            ExpressionLexer lexer = new ExpressionLexer( new StringReader( lambdaExpression ) );
            ExpressionParser parser = new SpringExpressionParser( lexer );

            try
            {
                parser.lambda();
            }
            catch (TokenStreamRecognitionException ex)
            {
                throw new SyntaxErrorException( ex.recog.Message, ex.recog.getLine(), ex.recog.getColumn(), lambdaExpression );
            }
            variables[functionName] = parser.getAST();
        }