private static bool WildcardStringMatch(FilterBase filter, string wildcardFilter, string property) { Regex extra = filter.Extra as Regex; if (extra == null) { extra = new Regex(SAMUtils.PAPIQueryToRegexString(wildcardFilter), RegexOptions.Singleline); filter.Extra = extra; } Match match = extra.Match(property); return(match.Success); }
// // Conversion routines // private static bool WildcardStringMatch(FilterBase filter, string wildcardFilter, string property) { // Build a Regex that matches valueToMatch, and store it on the Filter (so that we don't have // to have the CLR constantly reparse the regex string). // Ideally, we'd like to use a compiled Regex (RegexOptions.Compiled) for performance, // but the CLR cannot release generated MSIL. Thus, our memory usage would grow without bound // each time a query was performed. Regex regex = filter.Extra as Regex; if (regex == null) { regex = new Regex(SAMUtils.PAPIQueryToRegexString(wildcardFilter), RegexOptions.Singleline); filter.Extra = regex; } return(regex.IsMatch(property)); }