Skip to content

Commit a5ceb80

Browse files
committed
add extension
1 parent 7eb06fe commit a5ceb80

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

FluentCommandLineParser/Internals/Extensions/UsefulExtension.cs

+14
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2222
// POSSIBILITY OF SUCH DAMAGE.
2323
#endregion
24+
25+
using System.Collections.Generic;
26+
using System.Linq;
27+
2428
namespace Fclp.Internals.Extensions
2529
{
2630
/// <summary>
@@ -38,5 +42,15 @@ public static bool IsNullOrWhiteSpace(this string value)
3842
{
3943
return string.IsNullOrEmpty(value) || string.IsNullOrEmpty(value.Trim());
4044
}
45+
46+
/// <summary>
47+
/// Indicates whether the specified <see cref="IEnumerable{T}"/> is <c>null</c> or contains no elements.
48+
/// </summary>
49+
/// <param name="enumerable">A <see cref="IEnumerable{T}"/> to check.</param>
50+
/// <returns><c>true</c> if <paramref name="enumerable"/> is <c>null</c> or contains no elements; otherwise <c>false</c>.</returns>
51+
public static bool IsNullOrEmpty<TSource>(this IEnumerable<TSource> enumerable)
52+
{
53+
return enumerable == null || enumerable.Any() == false;
54+
}
4155
}
4256
}

0 commit comments

Comments
 (0)