/// <summary>
        /// Indicates that the given sub-expression is the next expected, giving it a
        /// name and specifying whether it is required.
        /// </summary>
        /// <param name="itemName">The name that the sub-expression will be identified with in the outer expression.</param>
        /// <param name="isRequired">Indicates whether the sub-expression is required in order for the expression to match.</param>
        /// <param name="definition">The definition for the sub-expression.</param>
        /// <returns>The updated definition.</returns>
        public ExpressionDefinition Add(string itemName, bool isRequired, ExpressionDefinition definition)
        {
            if (definition == null)
            {
                throw new ArgumentNullException("definition");
            }
            IExpressionItem item = new Expression(definition);

            items.Add(new ExpressionItem(itemName, isRequired, item));
            return(this);
        }
Example #2
0
        /// <summary>
        /// Indicates that the given sub-expression is the next expected, giving it a
        /// name and specifying whether it is required.
        /// </summary>
        /// <param name="itemName">The name that the token will be identified with in the outer expression.</param>
        /// <param name="definition">The definition for the sub-expression.</param>
        /// <returns>The updated expression.</returns>
        public Options Add(string itemName, ExpressionDefinition definition)
        {
            if (definition == null)
            {
                throw new ArgumentNullException("definition");
            }
            IExpressionItem item = new Expression(definition);

            options.Add(new ExpressionItem(itemName, false, item));
            return(this);
        }
Example #3
0
        /// <summary>
        /// Creates or retrieves the expression definition associated with the given name.
        /// </summary>
        /// <param name="type">The identifier to use to refer to the expression type later.</param>
        /// <returns>The expression definition to allow for configuration.</returns>
        public ExpressionDefinition Define(string type)
        {
            if (String.IsNullOrWhiteSpace(type))
            {
                throw new ArgumentException(Resources.BlankExpressionType, "type");
            }
            ExpressionDefinition definition;

            if (!expressionLookup.TryGetValue(type, out definition))
            {
                definition = new ExpressionDefinition(type);
                expressionLookup.Add(type, definition);
            }
            return(definition);
        }
Example #4
0
        /// <summary>
        /// Creates or retrieves the expression definition associated with the given name.
        /// </summary>
        /// <param name="type">The identifier to use to refer to the expression type later.</param>
        /// <returns>The expression definition to allow for configuration.</returns>
        public ExpressionDefinition Define(string type)
        {
            if (String.IsNullOrWhiteSpace(type))
            {
                throw new ArgumentException("Encountered a null or blank expression type.");
            }
            ExpressionDefinition definition;

            if (!expressionLookup.TryGetValue(type, out definition))
            {
                definition = new ExpressionDefinition(type);
                expressionLookup.Add(type, definition);
            }
            return(definition);
        }
Example #5
0
        /// <summary>
        /// Creates a sub-expression definition.
        /// </summary>
        /// <returns>The expression definition to allow for configuration.</returns>
        public ExpressionDefinition Define()
        {
            ExpressionDefinition definition = new ExpressionDefinition(null);

            return(definition);
        }
Example #6
0
        /// <summary>
        /// Gets a placeholder to indicate that one of many expressions is next in an expression.
        /// </summary>
        /// <param name="type">The type of the expression for future reference.</param>
        /// <returns>The options placeholder.</returns>
        public Expression Expression(string type)
        {
            ExpressionDefinition definition = Define(type);

            return(new Expression(definition));
        }
Example #7
0
 /// <summary>
 /// Initializes a new instance of an Expression.
 /// </summary>
 /// <param name="expression">The sequence of tokens and sub-expressions expected to appear.</param>
 internal Expression(ExpressionDefinition expression)
 {
     this.expression = expression;
 }