Пример #1
0
        /// <summary>
        /// Adds the specified columns, and optionally default filter and search rules.
        /// </summary>
        /// <param name="column">The column to add.</param>
        /// <param name="addDefaultFilterRules">Whether to add default filter rules for the specified column.</param>
        /// <exception cref="ArgumentNullException">The specified value is a null reference.</exception>
        public void AddColumn(InnerListColumn column, bool addDefaultFilterRules)
        {
            if (column == null)
            {
                throw new ArgumentNullException("column");
            }

            this.List.Columns.Add(column);

            if (addDefaultFilterRules)
            {
                Type               genericSelectorRuleType     = typeof(PropertyValueSelectorFilterRule <>).MakeGenericType(column.DataDescription.DataType);
                ConstructorInfo    selectorRuleConstructorInfo = genericSelectorRuleType.GetConstructor(new Type[] { typeof(string), typeof(string) });
                SelectorFilterRule selectorRule = (SelectorFilterRule)selectorRuleConstructorInfo.Invoke(new object[] { column.DataDescription.PropertyName, column.DataDescription.DisplayName });

                if (addDefaultFilterRules)
                {
                    this.AddFilterRulePicker.ColumnFilterRules.Add(new AddFilterRulePickerItem(new FilterRulePanelItem(selectorRule, selectorRule.DisplayName)));
                }

                // Automatically add a search rule if the search box is shown \\
                if (this.IsSearchShown)
                {
                    this.SearchBox.Parser.TryAddSearchableRule <TextContainsFilterRule>(selectorRule);

                    // Add this property to the full-text search properties \\
                    this.defaultFullTextSearchRule.PropertyNames.Add(column.DataDescription.PropertyName);
                }
            }
        }
Пример #2
0
            /// <summary>
            /// Gets a rule with the specified search value set.
            /// </summary>
            /// <param name="value">The search value.</param>
            /// <returns>A rule with the specified search value set.</returns>
            /// <exception cref="ArgumentNullException">The specified value is a null reference.</exception>
            public SelectorFilterRule GetRuleWithValueSet(string value)
            {
                if (value == null)
                {
                    throw new ArgumentNullException("value");
                }

                SelectorFilterRule selectorRule = (SelectorFilterRule)this.selectorFilterRule.DeepCopy();

                selectorRule.AvailableRules.SelectedIndex = this.selectorFilterRule.AvailableRules.AvailableValues.IndexOf(this.childRule);
                ((TextFilterRule)selectorRule.AvailableRules.SelectedValue).Value.Value = value;

                return(selectorRule);
            }
Пример #3
0
        /// <summary>
        /// Allows the specified rule to be included in the search expression.
        /// The rule must have an available rule of type <typeparamref name="T"/> that will be set with the search value.
        /// </summary>
        /// <typeparam name="T">The type of the text rule within the specified selector rule.</typeparam>
        /// <param name="selectorRule">The rule to include in the search expression.</param>
        /// <returns><c>true</c> if a rule of type <typeparamref name="T"/> was added; otherwise, <c>false</c>.</returns>
        /// <exception cref="ArgumentNullException">The specified value is a null reference.</exception>
        public bool TryAddSearchableRule <T>(SelectorFilterRule selectorRule)
            where T : TextFilterRule
        {
            if (selectorRule == null)
            {
                throw new ArgumentNullException("selectorRule");
            }

            T textRule = selectorRule.AvailableRules.AvailableValues.Find <T>();

            if (textRule != null)
            {
                SearchableRule rule = new SearchableRule("RULE_" + this.SearchableRules.Count.ToString(CultureInfo.InvariantCulture), selectorRule, textRule);

                this.SearchableRules.Add(rule);

                return(true);
            }

            return(false);
        }
Пример #4
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);
            }