internal static void AppendKeywordOrClause(StringBuilder query, PropertyKeyword keyword, ICollection <string> valuesToQuery) { EnumValidator.ThrowIfInvalid <PropertyKeyword>(keyword); if (valuesToQuery != null && valuesToQuery.Count > 0) { bool flag = false; foreach (string value in valuesToQuery) { if (!string.IsNullOrEmpty(value)) { if (!flag) { flag = true; AqsQueryBuilder.AppendLeadingSpaceIfNecessary(query); query.Append(keyword.ToString().ToLower()).Append(":("); } else { query.Append(AqsQueryBuilder.AqsQueryORSeparator); } query.Append("\"").Append(value).Append("\""); } } if (flag) { query.Append(")"); } } }
public void 方法关键字转换属性关键字() { MethodKeyword methodKeyword = MethodKeyword.Abstract; PropertyKeyword propertyKeyword = EnumCache.ToPropertyKeyword(methodKeyword); Assert.Equal(PropertyKeyword.Abstract, propertyKeyword); }
internal static void AppendDateClause(StringBuilder query, PropertyKeyword keyword, DateRangeQueryOperation operation, DateTime date) { EnumValidator.ThrowIfInvalid <PropertyKeyword>(keyword, AqsQueryBuilder.ValidDateKeywords); EnumValidator.ThrowIfInvalid <DateRangeQueryOperation>(operation); AqsQueryBuilder.AppendLeadingSpaceIfNecessary(query); query.Append(keyword.ToString().ToLower()).Append(":("); switch (operation) { case DateRangeQueryOperation.Equal: query.Append("="); break; case DateRangeQueryOperation.GreaterThan: query.Append(">"); break; case DateRangeQueryOperation.GreaterThanOrEqual: query.Append(">="); break; case DateRangeQueryOperation.LessThan: query.Append("<"); break; case DateRangeQueryOperation.LessThanOrEqual: query.Append("<="); break; } query.Append(date.ToLocalTime().ToString(AqsQueryBuilder.AqsDateTimeFormat, CultureInfo.InvariantCulture)); query.Append(")"); }
public bool TryGetPropertyKeyword(string name, out PropertyKeyword propertyKeyword) { if (this.propertyKeywordMapping.TryGetValue(name, out propertyKeyword)) { return(true); } propertyKeyword = PropertyKeyword.All; return(false); }
public void 属性关键字() { PropertyKeyword propertyKeyword = PropertyKeyword.Abstract; var output = EnumCache.GetPropertyKeyword(propertyKeyword); Assert.Equal("abstract", output); output = EnumCache.GetValue(propertyKeyword); Assert.Equal("abstract", output); }
private bool TryGetCurrentPropertyKeyword(out PropertyKeyword propertyKeyword) { if (string.IsNullOrEmpty(this.currentScope)) { propertyKeyword = PropertyKeyword.All; return(true); } if (!this.keywordMapping.TryGetPropertyKeyword(this.currentScope, out propertyKeyword)) { return(false); } if (!this.AllowedKeywords.Contains(propertyKeyword)) { propertyKeyword = PropertyKeyword.All; return(false); } return(true); }
public static string GetPropertyKeyword(PropertyKeyword value) { return(_PropertyKeyword.Value[value]); }
/// <summary> /// 设置字段的关键字,如 static,readonly 等 /// </summary> /// <param name="keyword">字段修饰符</param> /// <returns></returns> public virtual TBuilder WithKeyword(PropertyKeyword keyword = PropertyKeyword.Default) { _variable.Keyword = EnumCache.GetValue(keyword); return(_TBuilder); }
/// <summary> /// 设置字段的关键字,如 static,readonly 等 /// </summary> /// <param name="keyword">字段修饰符</param> /// <returns></returns> public virtual TBuilder WithKeyword(PropertyKeyword keyword = PropertyKeyword.Default) { _variable.Keyword = RoslynHelper.GetName(keyword); return(_TBuilder); }
internal QueryFilter BuildAllFilter(ConditionOperation opt, object value) { PropertyKeyword[] array2; switch (this.RescopedAll) { case RescopedAll.Default: return(this.BuildTextFilter(this.allMapping, (string)value, opt)); case RescopedAll.Subject: { PropertyKeyword[] array = new PropertyKeyword[1]; array2 = array; break; } case RescopedAll.Body: array2 = new PropertyKeyword[] { PropertyKeyword.Body }; break; case RescopedAll.BodyAndSubject: array2 = new PropertyKeyword[] { PropertyKeyword.Subject, PropertyKeyword.Body }; break; case RescopedAll.From: array2 = new PropertyKeyword[] { PropertyKeyword.From }; break; case RescopedAll.Participants: array2 = new PropertyKeyword[] { PropertyKeyword.Participants }; break; default: throw new ArgumentException("RescopedAll"); } List <QueryFilter> list = new List <QueryFilter>(); foreach (PropertyKeyword key in array2) { QueryFilter queryFilter = this.filterBuilderMap[key](opt, value); if (queryFilter != null) { list.Add(queryFilter); } } if (list.Count <= 0) { return(null); } if (list.Count <= 1) { return(list[0]); } return(new OrFilter(list.ToArray())); }
private void ValidatePredicate(Solution solution, LeafCondition leaf, List <ParserErrorInfo> errors, bool postResolving) { this.ValidatePredicateOperator(solution, leaf, errors); TokenInfo errorToken = (leaf.PropertyTermInfo == null) ? null : new TokenInfo(solution.Tokens[leaf.PropertyTermInfo.FirstToken]); PropertyKeyword propertyKeyword; if (postResolving) { if (!AqsParser.PropertyKeywordMap.TryGetValue(leaf.PropertyName, out propertyKeyword)) { propertyKeyword = PropertyKeyword.All; } } else if (leaf.PropertyTermInfo != null) { if (!AqsParser.PropertyKeywordMap.TryGetValue(leaf.PropertyName, out propertyKeyword)) { errors.Add(new ParserErrorInfo(ParserErrorCode.InvalidPropertyKey, errorToken)); return; } if (!this.AllowedKeywords.Contains(propertyKeyword)) { errors.Add(new ParserErrorInfo(ParserErrorCode.InvalidPropertyKey, errorToken)); return; } } else { propertyKeyword = PropertyKeyword.All; if (leaf.ValueTermInfo == null) { errors.Add(new ParserErrorInfo(ParserErrorCode.UnexpectedToken)); return; } } if (!postResolving && leaf.ValueTermInfo == null) { ParserErrorCode parserErrorCode = ParserErrorCode.MissingPropertyValue; PropertyKeyword propertyKeyword2 = propertyKeyword; switch (propertyKeyword2) { case PropertyKeyword.Sent: case PropertyKeyword.Received: parserErrorCode = ParserErrorCode.InvalidDateTimeFormat; break; default: if (propertyKeyword2 == PropertyKeyword.Kind) { parserErrorCode = ParserErrorCode.InvalidKindFormat; } break; } if (parserErrorCode != ParserErrorCode.MissingPropertyValue) { int num = leaf.PropertyTermInfo.FirstToken + leaf.PropertyTermInfo.Length + 1; if (leaf.OperationTermInfo != null) { num += leaf.PropertyTermInfo.Length; } if (num < solution.Tokens.Count) { errorToken = new TokenInfo(solution.Tokens[num]); } } errors.Add(new ParserErrorInfo(parserErrorCode, errorToken)); return; } if (leaf.ValueTermInfo != null) { int firstChar = solution.Tokens[leaf.ValueTermInfo.FirstToken].FirstChar; errorToken = new TokenInfo(firstChar, leaf.ValueTermInfo.Text.Length); } if (propertyKeyword == PropertyKeyword.Kind) { if (!AqsParser.KindKeywordMap.ContainsKey((string)leaf.Value)) { errors.Add(new ParserErrorInfo(ParserErrorCode.InvalidKindFormat, errorToken)); return; } } else { if (propertyKeyword == PropertyKeyword.Sent || propertyKeyword == PropertyKeyword.Received) { if (postResolving || !(leaf.Value is string[]) || ((string[])leaf.Value).Length != 2) { return; } using (Condition condition = solution.Resolve(leaf, 0, (DateTime)ExDateTime.Now)) { LeafCondition leafCondition = (LeafCondition)((CompoundCondition)condition).Children[0]; LeafCondition leafCondition2 = (LeafCondition)((CompoundCondition)condition).Children[1]; ExDateTime t = (ExDateTime)((DateTime)leafCondition.Value); ExDateTime t2 = (ExDateTime)((DateTime)leafCondition2.Value); if (t > t2) { errors.Add(new ParserErrorInfo(ParserErrorCode.InvalidDateTimeRange, errorToken)); } return; } } if (postResolving && leaf.Value is string) { string text = (string)leaf.Value; if (!AqsParser.ContainsAlphanumericChars(text)) { errors.Add(new ParserErrorInfo(ParserErrorCode.UnexpectedToken, errorToken)); } int num2 = text.IndexOf('*'); if (num2 >= 0) { string s = text.Substring(0, num2); if (!AqsParser.ContainsAlphanumericChars(s)) { errors.Add(new ParserErrorInfo(ParserErrorCode.SuffixMatchNotSupported, errorToken)); } } } } }
private static Type GetPropertyKeywordType(PropertyKeyword propertyKeyword) { return(Globals.PropertyKeywordToDefinitionMap[propertyKeyword][0].Type); }