Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class CollectionExtensions
- {
- public static bool IsNullOrEmpty<T>(this IEnumerable<T> items)
- {
- return items == null || !items.Any();
- }
- public static bool IsNotNullNorEmpty<T>(this IEnumerable<T> items)
- {
- return items != null && items.Any();
- }
- public static bool IsEmpty(this IEnumerable collection)
- {
- var enumerator = collection.GetEnumerator();
- var isEmpty = !enumerator.MoveNext();
- return isEmpty;
- }
- public static bool IsNotEmpty(this IEnumerable collection)
- {
- return !IsEmpty(collection);
- }
- public static bool IsEmpty(this ICollection collection)
- {
- return collection.Count == 0;
- }
- public static bool IsNotEmpty(this ICollection collection)
- {
- return !IsEmpty(collection);
- }
- public static bool IsNullOrEmpty(this IEnumerable collection)
- {
- return collection is null || IsEmpty(collection);
- }
- public static bool IsNotNullNorEmpty(this IEnumerable collection)
- {
- return !IsNullOrEmpty(collection);
- }
- public static bool IsNullOrEmpty(this ICollection collection)
- {
- return collection is null || IsEmpty(collection);
- }
- public static bool IsNotNullNorEmpty(this ICollection collection)
- {
- return !IsNullOrEmpty(collection);
- }
- public static void AddRange<T>(this ObservableCollection<T> collection, IEnumerable<T> items)
- {
- foreach (var item in items)
- {
- collection.Add(item);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement