persistence/DD.Persistence/Extensions/IEnumerableExtensions.cs
Roman Efremov a3605253d6
Some checks failed
Unit tests / test (push) Failing after 3m21s
Метод Get с массивом дискриминаторов
2025-01-23 17:33:01 +05:00

36 lines
849 B
C#

namespace DD.Persistence.Extensions;
/// <inheritdoc/>
public static class IEnumerableExtensions
{
/// <inheritdoc/>
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);
}
}
/// <inheritdoc/>
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();
}
}