public void IsMatch(string pattern, string input, bool isMatch, WildcardPatternOptions options = default, StringComparison comparsionType = default, string culture = null) { using (culture is null ? CultureInfoScope.NewInvariant() : new CultureInfoScope("tr-TR")) { var actual = WildcardPattern.IsMatch(pattern, input, options, comparsionType); Assert.AreEqual(isMatch, actual, "'{0}' should {2} match '{1}', with {3} and {4}.", pattern, input, isMatch ? "" : "not ", options, comparsionType); } }
/// <summary>Initializes a new instance of a wild card pattern.</summary> /// <param name="pattern"> /// The pattern to match on. /// </param> /// <param name="options"> /// The wildcard pattern options. /// </param> /// <param name="comparisonType"> /// The type of comparison. /// </param> /// <exception cref="ArgumentNullException"> /// pattern is null. /// </exception> /// <exception cref="ArgumentException"> /// pattern is empty or invalid. /// </exception> public WildcardPattern(string pattern, WildcardPatternOptions options, StringComparison comparisonType) : this() { Pattern = Guard.NotNullOrEmpty(pattern, "pattern"); if (options.HasFlag(WildcardPatternOptions.SqlWildcards)) { if (pattern.Contains("%%")) { throw new ArgumentException(QowaivMessages.ArgumentException_InvalidWildcardPattern, "pattern"); } SingleChar = '_'; MultipleChars = '%'; } else if (pattern.Contains("**")) { throw new ArgumentException(QowaivMessages.ArgumentException_InvalidWildcardPattern, "pattern"); } Options = options; ComparisonType = comparisonType; }
/// <summary>Initializes a new instance of a wild card pattern.</summary> /// <param name="pattern"> /// The pattern to match on. /// </param> /// <param name="options"> /// The wildcard pattern options. /// </param> /// <param name="comparisonType"> /// The type of comparison. /// </param> /// <exception cref="ArgumentNullException"> /// pattern is null. /// </exception> /// <exception cref="ArgumentException"> /// pattern is empty or invalid. /// </exception> public WildcardPattern(string pattern, WildcardPatternOptions options, StringComparison comparisonType) : this() { Pattern = Guard.NotNullOrEmpty(pattern, nameof(pattern)); if (options.HasFlag(WildcardPatternOptions.SqlWildcards)) { if (pattern.Contains("%%")) { throw new ArgumentException(QowaivMessages.ArgumentException_InvalidWildcardPattern, "pattern"); } SingleChar = '_'; MultipleChars = '%'; } else if (pattern.Contains("**")) { throw new ArgumentException(QowaivMessages.ArgumentException_InvalidWildcardPattern, "pattern"); } else /* No arugument exceptions. */ } {
private void IsMatch(string pattern, string input, bool isMatch, WildcardPatternOptions options = WildcardPatternOptions.None, StringComparison comparsionType = StringComparison.CurrentCulture) { Assert.AreEqual(isMatch, WildcardPattern.IsMatch(pattern, input, options, comparsionType), "'{0}' should {2} match '{1}', with {3} and {4}.", pattern, input, isMatch ? "" : "not ", options, comparsionType); }
/// <summary>Indicates whether the specified wildcard pattern finds a match in the specified input string.</summary> /// <param name="pattern"> /// The string that represents the wildcard pattern. /// </param> /// <param name="input"> /// The string to search for a match. /// </param> /// <param name="options"> /// The wildcard pattern options. /// </param> /// <param name="comparisonType"> /// The type of comparison. /// </param> /// <returns> /// true if the wildcard pattern finds a match; otherwise, false. /// </returns> /// <exception cref="ArgumentNullException"> /// input is null. /// </exception> public static bool IsMatch(string pattern, string input, WildcardPatternOptions options, StringComparison comparisonType) { var wildcard = new WildcardPattern(pattern, options, comparisonType); return wildcard.IsMatch(input); }
/// <summary>Indicates whether the specified wildcard pattern finds a match in the specified input string.</summary> /// <param name="pattern"> /// The string that represents the wildcard pattern. /// </param> /// <param name="input"> /// The string to search for a match. /// </param> /// <param name="options"> /// The wildcard pattern options. /// </param> /// <param name="comparisonType"> /// The type of comparison. /// </param> /// <returns> /// true if the wildcard pattern finds a match; otherwise, false. /// </returns> /// <exception cref="ArgumentNullException"> /// input is null. /// </exception> public static bool IsMatch(string pattern, string input, WildcardPatternOptions options, StringComparison comparisonType) { var wildcard = new WildcardPattern(pattern, options, comparisonType); return(wildcard.IsMatch(input)); }