/// <summary>
        /// Factory method that parses an unprocessed Expression string and returns an Expression
        /// of the appropriate type.
        /// </summary>
        /// <param name="rawExpression">An unprocessed string for a single expression.</param>
        /// <param name="project">The project where the expression exists.</param>
        /// <param name="task">The task where the expression exists.</param>
        /// <returns>A file expression class.</returns>
        public static FileExpressionBase ParseExpression(string rawExpression, ProjectInstance project, ProjectTaskInstance task)
        {
            string trimmedExpression = rawExpression.Trim();

            if (FileExpressionBatched.IsExpression(trimmedExpression))
            {
                return(new FileExpressionBatched(rawExpression, project, task));
            }

            if (FileExpressionTransform.IsExpression(rawExpression))
            {
                return(new FileExpressionTransform(trimmedExpression, project, task));
            }

            return(new FileExpressionLiteral(rawExpression, project, task));
        }
Beispiel #2
0
 /// <summary>
 /// Determines if an expression is a batch expression.
 /// </summary>
 /// <param name="trimmedExpression">The Expression string with leading and trailing whitespace removed.</param>
 /// <returns>True if trimmedExpression is a batch Expression.</returns>
 public static bool IsExpression(string trimmedExpression)
 {
     return(!FileExpressionTransform.IsExpression(trimmedExpression) &&
            trimmedExpression.IndexOf("%(", StringComparison.Ordinal) >= 0);
 }