コード例 #1
0
ファイル: QueryClause.cs プロジェクト: jonthegiant/StyleCop
 /// <summary>
 /// Initializes a new instance of the QueryClause class.
 /// </summary>
 /// <param name="proxy">Proxy object for the query clause.</param>
 /// <param name="type">The type of the clause.</param>
 internal QueryClause(CodeUnitProxy proxy,  QueryClauseType type) 
     : base(proxy, (int)type)
 {
     Param.AssertNotNull(proxy, "proxy");
     Param.Ignore(type);
     CsLanguageService.Debug.Assert(System.Enum.IsDefined(typeof(QueryClauseType), this.QueryClauseType), "The type is invalid.");
 }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the QueryClause class.
 /// </summary>
 /// <param name="proxy">Proxy object for the query clause.</param>
 /// <param name="type">The type of the clause.</param>
 internal QueryClause(CodeUnitProxy proxy, QueryClauseType type)
     : base(proxy, (int)type)
 {
     Param.AssertNotNull(proxy, "proxy");
     Param.Ignore(type);
     CsLanguageService.Debug.Assert(System.Enum.IsDefined(typeof(QueryClauseType), this.QueryClauseType), "The type is invalid.");
 }
コード例 #3
0
ファイル: QueryClause.cs プロジェクト: longzai2651/StyleCop2
        /// <summary>
        /// Initializes a new instance of the QueryClause class.
        /// </summary>
        /// <param name="type">
        /// The type of the clause.
        /// </param>
        /// <param name="tokens">
        /// The list of tokens that form the clause.
        /// </param>
        internal QueryClause(QueryClauseType type, CsTokenList tokens)
            : base(CodePartType.QueryClause, tokens)
        {
            Param.Ignore(type);
            Param.AssertNotNull(tokens, "tokens");

            this.type = type;
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the QueryClauseWithExpression class.
        /// </summary>
        /// <param name="type">The type of the query clause.</param>
        /// <param name="tokens">The list of tokens that form the clause.</param>
        /// <param name="expression">The range expression.</param>
        internal QueryClauseWithExpression(QueryClauseType type, CsTokenList tokens, Expression expression)
            : base(type, tokens)
        {
            Param.Ignore(type);
            Param.AssertNotNull(tokens, "tokens");
            Param.AssertNotNull(expression, "expression");

            this.expression = expression;

            this.AddExpression(expression);
        }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the QueryClauseWithExpression class.
        /// </summary>
        /// <param name="type">
        /// The type of the query clause.
        /// </param>
        /// <param name="tokens">
        /// The list of tokens that form the clause.
        /// </param>
        /// <param name="expression">
        /// The range expression.
        /// </param>
        internal QueryClauseWithExpression(QueryClauseType type, CsTokenList tokens, Expression expression)
            : base(type, tokens)
        {
            Param.Ignore(type);
            Param.AssertNotNull(tokens, "tokens");
            Param.AssertNotNull(expression, "expression");

            this.expression = expression;

            this.AddExpression(expression);
        }
コード例 #6
0
 public static LBooleanClause.Occur Translate(QueryClauseType type)
 {
     if (type == QueryClauseType.Required)
     {
         return LBooleanClause.Occur.MUST;
     }
     else if (type == QueryClauseType.Excluded)
     {
         return LBooleanClause.Occur.MUST_NOT;
     }
     else
     {
         return LBooleanClause.Occur.SHOULD;
     }
 }
コード例 #7
0
        internal static void Verify(ImmutableArray <QueryClause> clauses)
        {
            if (clauses.Length < 2)
            {
                throw new ArgumentException("Invalid clause body.", nameof(clauses));
            }
            if (clauses.Contains(null))
            {
                throw new ArgumentNullException(nameof(clauses));
            }

            // First clause must be in the "from .. in" form.
            if (clauses[0].ClauseType != QueryClauseType.From)
            {
                throw new ArgumentException("A query expression must begin with a from .. in clause.");
            }

            // Last clause must be in the "select .." or "group .." form.
            QueryClauseType lastClauseType = clauses[clauses.Length - 1].ClauseType;

            if (lastClauseType != QueryClauseType.Select && lastClauseType != QueryClauseType.GroupBy)
            {
                throw new ArgumentException("A query expression must end with a termination clause.");
            }

            // All other clauses cannot be termination clauses.
            for (int i = 1; i < clauses.Length - 1; i++)
            {
                switch (clauses[i].ClauseType)
                {
                case QueryClauseType.Select:
                case QueryClauseType.GroupBy:
                    throw new ArgumentException("A query expression cannot contain with a termination clause unless it is its last clause.");
                }
            }
        }