FruityFoundation/Base/Extensions/EnumerableExtensions.cs

10 lines
475 B
C#
Raw Normal View History

2022-09-23 21:08:00 -04:00
namespace FruityFoundation.Base.Extensions;
2022-09-23 21:07:42 -04:00
public static class EnumerableExtensions
{
public static IEnumerable<T> ConditionalConcat<T>(this IEnumerable<T> enumerable, bool isConditionValid, IEnumerable<T> second) =>
!isConditionValid ? enumerable : enumerable.Concat(second);
2022-09-23 21:08:00 -04:00
public static IEnumerable<T> ConditionalWhere<T>(this IEnumerable<T> enumerable, bool isConditionValid, Func<T, bool> pred) =>
!isConditionValid ? enumerable : enumerable.Where(pred);
2022-09-23 21:07:42 -04:00
}