String contains extension

This commit is contained in:
Jaex 2015-08-20 18:44:40 +03:00
parent 5ad848b9c8
commit 42c8f3f22a
2 changed files with 7 additions and 2 deletions

View file

@ -31,6 +31,11 @@ namespace ShareX.HelpersLib
{
public static class StringExtensions
{
public static bool Contains(this string str, string value, StringComparison comparisonType)
{
return str.IndexOf(value, comparisonType) >= 0;
}
public static string Left(this string str, int length)
{
if (length < 1) return string.Empty;

View file

@ -124,7 +124,7 @@ private HistoryItem[] ApplyFilters(HistoryItem[] historyItems)
if (!string.IsNullOrEmpty(host))
{
result = result.Where(x => !string.IsNullOrEmpty(x.Host) && x.Host.IndexOf(host, StringComparison.InvariantCultureIgnoreCase) >= 0);
result = result.Where(x => !string.IsNullOrEmpty(x.Host) && x.Host.Contains(host, StringComparison.InvariantCultureIgnoreCase));
}
}
@ -138,7 +138,7 @@ private HistoryItem[] ApplyFilters(HistoryItem[] historyItems)
if (cbFilenameFilterMethod.SelectedIndex == 0) // Contains
{
result = result.Where(x => x.Filename.IndexOf(filenameFilter, rule) >= 0);
result = result.Where(x => x.Filename.Contains(filenameFilter, rule));
}
else if (cbFilenameFilterMethod.SelectedIndex == 1) // Starts with
{