/// <summary>
        /// This parameter allows you to match the response data based on a regex
        /// filter on a specific field. One or more matching options will be
        /// translated into regex options.
        /// </summary>
        /// <param name="field">The field which should be matched.</param>
        /// <param name="value">The regex to match the field against.</param>
        /// <param name="matchingOptions">The regex options.</param>
        /// <returns>The request builder.</returns>
        public RequestBuilder <ModelType> MatchRegex(string field, object value, MatchingOption matchingOptions)
        {
            var _regexOptions = "";

            if (matchingOptions.HasFlag(MatchingOption.Global) == true)
            {
                _regexOptions += "g";
            }
            if (matchingOptions.HasFlag(MatchingOption.CaseInsensitive) == true)
            {
                _regexOptions += "i";
            }
            if (matchingOptions.HasFlag(MatchingOption.MultiLine) == true)
            {
                _regexOptions += "m";
            }
            if (matchingOptions.HasFlag(MatchingOption.SingleLine) == true)
            {
                _regexOptions += "s";
            }
            if (matchingOptions.HasFlag(MatchingOption.Unicode) == true)
            {
                _regexOptions += "u";
            }
            this.requestHandler.AddQueryParameter(name: $"match[{field}][$options]", value: _regexOptions);
            this.requestHandler.AddQueryParameter(name: $"match[{field}][$regex]", value: value);
            return(this);
        }
Example #2
0
            private IEnumerable <TestCaseData> GenerateForPartial()
            {
                var option = new MatchingOption {
                    Mode = MatchingMode.Partial
                };

                yield return(new TestCaseData("", option).Returns(true));

                yield return(new TestCaseData("test", option).Returns(true));

                yield return(new TestCaseData("Test", option).Returns(true));

                yield return(new TestCaseData("TEST", option).Returns(true));

                yield return(new TestCaseData("tEST", option).Returns(true));

                yield return(new TestCaseData("t", option).Returns(true));

                yield return(new TestCaseData("e", option).Returns(true));

                yield return(new TestCaseData("s", option).Returns(true));

                yield return(new TestCaseData("te", option).Returns(true));

                yield return(new TestCaseData("es", option).Returns(true));

                yield return(new TestCaseData("st", option).Returns(true));

                yield return(new TestCaseData("x", option).Returns(false));

                yield return(new TestCaseData("tst", option).Returns(false));
            }
        private void OnTextChanged(object sender, RoutedEventArgs e)
        {
            var textBox = Template.FindName("PART_TextBox", this) as TextBox;

            if (textBox == null || AutoCompleteItems.Count() == 0)
            {
                return;
            }

            if (!textBox.IsFocused)
            {
                return;
            }

            if (IsInQuote())
            {
                return;
            }

            var prev = GetPrevIndex();
            var next = GetNextIndex();

            if (next < prev)
            {
                return;
            }

            var popup   = Template.FindName("PART_AutocompletePopup", this) as Popup;
            var listBox = Template.FindName("PART_AutocompleteListBox", this) as ListBox;

            var context = textBox.Text.Substring(prev, next - prev + 1);

            var option = new MatchingOption {
                Mode = MatchingMode
            };
            var items = AutoCompleteItems.Where(o => o.IsMatch(context, option))
                        .Select((o, i) => new AutoCompleteItemWrapper(o.DisplayName, o.Description, o.Complete, i == 0));

            listBox.DataContext   = items;
            listBox.SelectedIndex = 0;
            popup.IsOpen          = items.Count() > 0;

            queryChanged = true;
        }
Example #4
0
 public bool IsMatchShouldWorkCorrectly(string value, MatchingOption option)
 {
     return(testee.IsMatch(value, option));
 }
Example #5
0
 public StringMatcher(MatchingOption matchingOption)
 {
     this._matchingOption = matchingOption;
 }