2025-01-20 17:11:44 +05:00
|
|
|
|
namespace DD.Persistence.Extensions;
|
2025-01-14 17:56:59 +05:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-01-17 17:21:54 +05:00
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
2025-01-14 17:56:59 +05:00
|
|
|
|
}
|