/// <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); ConditionExpression expression = parser.ParseExpression(); if (!parser.tokenizer.IsEOF()) { throw new ConditionParseException("Unexpected token: " + parser.tokenizer.TokenValue); } return expression; }
/// <summary> /// Parses the specified condition string and turns it into /// <see cref="ConditionExpression"/> tree. /// </summary> /// <param name="expr">The expression to be parsed.</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 expr) { ConditionParser parser = new ConditionParser(expr); ConditionExpression e = parser.ParseExpression(); if (!parser.tokenizer.IsEOF()) throw new ConditionParseException("Unexpected token: " + parser.tokenizer.TokenValue); return e; }
/// <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); ConditionExpression expression = parser.ParseExpression(); return expression; }
/// <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="nlogFactories">Instance of <see cref="NLogFactories"/> 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, NLogFactories nlogFactories) { ConditionParser parser = new ConditionParser(expressionText, nlogFactories); ConditionExpression expression = parser.ParseExpression(); if (!parser.tokenizer.IsEOF()) { throw new ConditionParseException("Unexpected token: " + parser.tokenizer.TokenValue); } return expression; }