Skip to content

Commit a7135b7

Browse files
committed
feat: Add ContainsIgnoreCase() extension method
1 parent ba1878d commit a7135b7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/VirtoCommerce.Platform.Core/Extensions/EnumerableExtensions.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@ public static bool IsNullOrEmpty<T>(this IEnumerable<T> data)
1414
return data == null || !data.Any();
1515
}
1616

17+
public static bool ContainsIgnoreCase(this IEnumerable<string> values, string value)
18+
{
19+
return values.Contains(value, StringComparer.OrdinalIgnoreCase);
20+
}
21+
1722
public static IEnumerable<IList<T>> Paginate<T>(this IEnumerable<T> items, int pageSize)
1823
{
1924
var page = new List<T>();
2025

21-
foreach (var item in items ?? Enumerable.Empty<T>())
26+
foreach (var item in items ?? [])
2227
{
2328
page.Add(item);
2429
if (page.Count >= pageSize)
@@ -42,7 +47,7 @@ public static IEnumerable<IList<T>> Paginate<T>(this IEnumerable<T> items, int p
4247
/// <remarks>If an exception occurs, the action will not be performed on the remaining items.</remarks>
4348
public static void Apply<T>(this IEnumerable<T> items, Action<T> action)
4449
{
45-
foreach (var item in items ?? Enumerable.Empty<T>())
50+
foreach (var item in items ?? [])
4651
{
4752
action(item);
4853
}
@@ -56,7 +61,7 @@ public static void Apply<T>(this IEnumerable<T> items, Action<T> action)
5661
/// <remarks>If an exception occurs, the action will not be performed on the remaining items.</remarks>
5762
public static void Apply<T>(this List<T> items, Action<T> action)
5863
{
59-
foreach (var item in items ?? Enumerable.Empty<T>())
64+
foreach (var item in items ?? [])
6065
{
6166
action(item);
6267
}

0 commit comments

Comments
 (0)