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); }
/// <summary> /// Checks the specified value whether or not can be completed by this item. /// </summary> /// <param name="value">The target value.</param> /// <param name="matchingOption">The option to specify matching rule.</param> /// <returns>True if the specified value can be completed by this item, otherwise false.</returns> public bool IsMatch(string value, MatchingOption matchingOption) { if (value == null) { throw new ArgumentNullException("value"); } if (matchingOption == null) { matchingOption = new MatchingOption(); } if (matchingOption.Mode == MatchingMode.Partial) { return DisplayName.ToUpperInvariant().Contains(value.ToUpperInvariant()); } else { return DisplayName.ToUpperInvariant().StartsWith(value.ToUpperInvariant(), StringComparison.OrdinalIgnoreCase); } }
/// <summary> /// Checks the specified value whether or not can be completed by this item. /// </summary> /// <param name="value">The target value.</param> /// <param name="matchingOption">The option to specify matching rule.</param> /// <returns>True if the specified value can be completed by this item, otherwise false.</returns> public bool IsMatch(string value, MatchingOption matchingOption) { if (value == null) { throw new ArgumentNullException("value"); } if (matchingOption == null) { matchingOption = new MatchingOption(); } if (matchingOption.Mode == MatchingMode.Partial) { return(DisplayName.ToUpperInvariant().Contains(value.ToUpperInvariant())); } else { return(DisplayName.ToUpperInvariant().StartsWith(value.ToUpperInvariant(), StringComparison.OrdinalIgnoreCase)); } }
/// <summary> /// Get the completed value. /// </summary> /// <param name="value">The target value.</param> /// <param name="matchingOption">The option to specify matching rule.</param> /// <returns>The completed value.</returns> public string Complete(string value, MatchingOption matchingOption) { return DisplayName; }
/// <summary> /// Get the completed value. /// </summary> /// <param name="value">The target value.</param> /// <param name="matchingOption">The option to specify matching rule.</param> /// <returns>The completed value.</returns> public string Complete(string value, MatchingOption matchingOption) { return(_completeProcedure(value, matchingOption)); }
/// <summary> /// Checks the specified value whether or not can be completed by this item. /// </summary> /// <param name="value">The target value.</param> /// <param name="matchingOption">The option to specify matching rule.</param> /// <returns>True if the specified value can be completed by this item, otherwise false.</returns> public bool IsMatch(string value, MatchingOption matchingOption) { return(_isMatchProcedure(value, matchingOption)); }
/// <summary> /// Get the completed value. /// </summary> /// <param name="value">The target value.</param> /// <param name="matchingOption">The option to specify matching rule.</param> /// <returns>The completed value.</returns> public string Complete(string value, MatchingOption matchingOption) { return(DisplayName); }
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; }
public bool IsMatchShouldWorkCorrectly(string value, MatchingOption option) { return testee.IsMatch(value, option); }
/// <summary> /// Get the completed value. /// </summary> /// <param name="value">The target value.</param> /// <param name="matchingOption">The option to specify matching rule.</param> /// <returns>The completed value.</returns> public string Complete(string value, MatchingOption matchingOption) { return completeProcedure(value, matchingOption); }
/// <summary> /// Checks the specified value whether or not can be completed by this item. /// </summary> /// <param name="value">The target value.</param> /// <param name="matchingOption">The option to specify matching rule.</param> /// <returns>True if the specified value can be completed by this item, otherwise false.</returns> public bool IsMatch(string value, MatchingOption matchingOption) { return isMatchProcedure(value, matchingOption); }