Esempio n. 1
0
        /// <summary>
        ///     Parses the specified condition string and turns it into
        ///     <see cref="ConditionExpression" /> tree.
        /// </summary>
        /// <param name="expressionText">The expression to be parsed.</param>
        /// <param name="configurationItemFactories">
        ///     Instance of <see cref="ConfigurationItemFactory" /> used to resolve references to condition methods and layout renderers.
        /// </param>
        /// <returns>The root of the expression syntax tree which can be used to get the value of the condition in a specified context.</returns>
        public static ConditionExpression ParseExpression(string expressionText, ConfigurationItemFactory configurationItemFactories)
        {
            if (expressionText == null)
            {
                return null;
            }

            var parser = new ConditionParser(new SimpleStringReader(expressionText), configurationItemFactories);
            var expression = parser.ParseExpression();
            if (!parser.tokenizer.IsEOF())
            {
                throw new ConditionParseException("Unexpected token: " + parser.tokenizer.TokenValue);
            }

            return expression;
        }
Esempio n. 2
0
        /// <summary>
        ///     Parses the specified condition string and turns it into
        ///     <see cref="ConditionExpression" /> tree.
        /// </summary>
        /// <param name="stringReader">The string reader.</param>
        /// <param name="configurationItemFactories">
        ///     Instance of <see cref="ConfigurationItemFactory" /> used to resolve references to condition methods and layout renderers.
        /// </param>
        /// <returns>
        ///     The root of the expression syntax tree which can be used to get the value of the condition in a specified context.
        /// </returns>
        internal static ConditionExpression ParseExpression(SimpleStringReader stringReader, ConfigurationItemFactory configurationItemFactories)
        {
            var parser = new ConditionParser(stringReader, configurationItemFactories);
            var expression = parser.ParseExpression();

            return expression;
        }