/// <summary>
        ///  Add a component clause to the query.
        /// </summary>
        /// <param name="component">
        /// </param>
        /// <param name="clause">
        /// </param>
        /// <param name="engineCode">
        /// </param>
        /// <returns>
        /// </returns>
        public Q AddComponent(string component, ClauseBase clause, string engineCode = null)
        {
            if (engineCode == null)
            {
                engineCode = EngineScope;
            }

            clause.Engine    = engineCode;
            clause.Component = component;
            Clauses.Add(clause);

            return((Q)this);
        }
        /// <summary>
        ///  If the query already contains a clause for the given component and engine, replace it
        ///  with the specified clause. Otherwise, just add the clause.
        /// </summary>
        /// <param name="component">
        /// </param>
        /// <param name="clause">
        /// </param>
        /// <param name="engineCode">
        /// </param>
        /// <returns>
        /// </returns>
        public Q AddOrReplaceComponent(string component, ClauseBase clause, string engineCode = null)
        {
            engineCode = engineCode ?? EngineScope;

            ClauseBase current = GetComponents(component).SingleOrDefault(c => c.Engine == engineCode);

            if (current != null)
            {
                Clauses.Remove(current);
            }

            return(AddComponent(component, clause, engineCode));
        }
Exemple #3
0
 private InvalidCastException InvalidClauseException(string section, ClauseBase clause)
 {
     return(new InvalidCastException($"Invalid type \"{clause.GetType().Name}\" provided for the \"{section}\" clause."));
 }