Completes: U4-4670 Add .ContainsAny string extension to Umbraco.Core.StringExtensions

This commit is contained in:
Shannon
2014-04-16 17:01:26 +10:00
parent 2f679a52f4
commit d953966248
2 changed files with 14 additions and 24 deletions

View File

@@ -1180,5 +1180,15 @@ namespace Umbraco.Core
*/
}
public static bool ContainsAny(this string haystack, IEnumerable<string> needles, StringComparison comparison = StringComparison.CurrentCulture)
{
if (haystack == null) throw new ArgumentNullException("haystack");
if (string.IsNullOrEmpty(haystack) == false || needles.Any())
{
return needles.Any(value => haystack.IndexOf(value) >= 0);
}
return false;
}
}
}