예제 #1
0
        private List <SearchTextParseResult> ParseMatches(MatchCollection matches)
        {
            List <SearchTextParseResult> searchBoxItems = new List <SearchTextParseResult>(matches.Count);

            foreach (Match match in matches)
            {
                string value = match.Groups[ValueGroupName].Value;

                if (match.Groups[FullTextRuleGroupName].Success && this.FullTextRule != null)
                {
                    TextFilterRule fullTextRule = (TextFilterRule)this.FullTextRule.DeepCopy();
                    fullTextRule.Value.Value = value;

                    searchBoxItems.Add(new SearchTextParseResult(fullTextRule));
                }
                else
                {
                    foreach (SearchableRule rule in this.SearchableRules)
                    {
                        if (match.Groups[rule.UniqueId].Success)
                        {
                            searchBoxItems.Add(new SearchTextParseResult(rule.GetRuleWithValueSet(value)));
                        }
                    }
                }
            }

            return(searchBoxItems);
        }
예제 #2
0
        private bool TryGetGenericParameterForComparableValueFilterRule(FilterRule rule, out Type genericParameter)
        {
            genericParameter = null;

            TextFilterRule textRule = rule as TextFilterRule;

            if (null != textRule)
            {
                genericParameter = typeof(string);
                return(true);
            }

            Type ruleType = rule.GetType();

            if (!ruleType.IsGenericType)
            {
                return(false);
            }

            genericParameter = ruleType.GetGenericArguments()[0];
            return(true);
        }
예제 #3
0
            /// <summary>
            /// Initializes a new instance of <see cref="SearchableRule"/> with the specified unique ID, selector rule, and child rule.
            /// </summary>
            /// <param name="uniqueId">A unique ID for this instance.</param>
            /// <param name="selectorFilterRule">A selector rule that contains <paramref name="childRule"/>.</param>
            /// <param name="childRule">A text rule within <paramref name="selectorFilterRule"/>.</param>
            /// <exception cref="ArgumentNullException">The specified value is a null reference.</exception>
            public SearchableRule(string uniqueId, SelectorFilterRule selectorFilterRule, TextFilterRule childRule)
            {
                if (uniqueId == null)
                {
                    throw new ArgumentNullException("uniqueId");
                }

                if (selectorFilterRule == null)
                {
                    throw new ArgumentNullException("selectorFilterRule");
                }

                if (childRule == null)
                {
                    throw new ArgumentNullException("childRule");
                }

                this.UniqueId           = uniqueId;
                this.selectorFilterRule = selectorFilterRule;
                this.childRule          = childRule;
                this.Pattern            = String.Format(CultureInfo.InvariantCulture, "(?<{0}>){1}\\s*:\\s*{2}", uniqueId, Regex.Escape(selectorFilterRule.DisplayName), SearchTextParser.ValuePattern);
            }
예제 #4
0
 /// <summary>
 /// Removes the searchable rules, including the full-text rule.
 /// </summary>
 public void ClearSearchableRules()
 {
     this.SearchableRules.Clear();
     this.FullTextRule = null;
 }