using System.Linq; using JSMachine.DCS.Infrastructure; using JSMachine.WMS.Infrastructure; // ReSharper disable once CheckNamespace namespace System.Collections.Generic { public static class EnumerableExtensions { public static void ForEach(this IEnumerable @this, Action callback, bool immutable = false) { Guards.ThrowIfNull(@this, callback); var collection = immutable ? @this.ToArray() : @this; foreach (T item in collection) { callback(item); } } public static IEnumerable Do(this IEnumerable @this, Action callback) { Guards.ThrowIfNull(@this, callback); foreach (var item in @this) { callback?.Invoke(item); yield return item; } } //public static bool IsNullOrEmpty(this IEnumerable source) //{ // return source == null || source.Count() == 0; //} public static bool IsNullOrEmpty(this IList source) { return source == null || source.Count == 0; } } }