public static bool NewIsWildcardMatch(this string text, string wildcardMask, bool isMatchingLocation = false, string currentLocation = null) {
string key;
if (!isMatchingLocation) {
key = (currentLocation ?? "") + wildcardMask;
lock (NewWildcards) {
if (!NewWildcards.ContainsKey(key)) {
NewWildcards.Add(key, WildcardToRegex(key));
}
}
return NewWildcards[key].IsMatch(text);
}
key = wildcardMask + (currentLocation ?? "");
if (!NewWildcards.ContainsKey(key)) {
var prefix = currentLocation == null
? @".*[\\|\/]"
: Regex.Escape((currentLocation.EndsWith("\\") || currentLocation.EndsWith("/")
? currentLocation
: currentLocation + (text.Contains("\\") ? "\\" : (text.Contains("/") ? "/" : ""))));
NewWildcards.Add(key, WildcardToRegex(wildcardMask, prefix));
}
return NewWildcards[key].IsMatch(text);
}