persistence/DD.Persistence.Repository/Extensions/IEnumerableExtensions.cs
Roman Efremov fd276f5a43
Some checks failed
Unit tests / test (push) Failing after 55s
Доработки
2025-01-17 17:21:54 +05:00

33 lines
798 B
C#

namespace DD.Persistence.Repository.Extensions;
public static class IEnumerableExtensions
{
public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
if (action == null)
throw new ArgumentNullException(nameof(action));
foreach (var item in source)
{
action(item);
}
}
public static bool IsNullOrEmpty<T>(this IEnumerable<T>? enumerable)
{
if (enumerable == null)
{
return true;
}
var collection = enumerable as ICollection<T>;
if (collection != null)
{
return collection.Count < 1;
}
return !enumerable.Any();
}
}