Class AbpCollectionExtensions
- Namespace
- System.Collections.Generic
- Assembly
- Volo.Abp.Core.dll
Extension methods for Collections.
public static class AbpCollectionExtensions
- Inheritance
-
AbpCollectionExtensions
- Inherited Members
Methods
AddIfNotContains<T>(ICollection<T>, IEnumerable<T>)
Adds items to the collection which are not already in the collection.
public static IEnumerable<T> AddIfNotContains<T>(this ICollection<T> source, IEnumerable<T> items)
Parameters
source
ICollection<T>The collection
items
IEnumerable<T>Item to check and add
Returns
- IEnumerable<T>
Returns the added items.
Type Parameters
T
Type of the items in the collection
AddIfNotContains<T>(ICollection<T>, Func<T, bool>, Func<T>)
Adds an item to the collection if it's not already in the collection based on the given predicate
.
public static bool AddIfNotContains<T>(this ICollection<T> source, Func<T, bool> predicate, Func<T> itemFactory)
Parameters
source
ICollection<T>The collection
predicate
Func<T, bool>The condition to decide if the item is already in the collection
itemFactory
Func<T>A factory that returns the item
Returns
- bool
Returns True if added, returns False if not.
Type Parameters
T
Type of the items in the collection
AddIfNotContains<T>(ICollection<T>, T)
Adds an item to the collection if it's not already in the collection.
public static bool AddIfNotContains<T>(this ICollection<T> source, T item)
Parameters
source
ICollection<T>The collection
item
TItem to check and add
Returns
- bool
Returns True if added, returns False if not.
Type Parameters
T
Type of the items in the collection
IsNullOrEmpty<T>(ICollection<T>?)
Checks whatever given collection object is null or has no item.
public static bool IsNullOrEmpty<T>(this ICollection<T>? source)
Parameters
source
ICollection<T>
Returns
Type Parameters
T
RemoveAll<T>(ICollection<T>, IEnumerable<T>)
Removes all items from the collection.
public static void RemoveAll<T>(this ICollection<T> source, IEnumerable<T> items)
Parameters
source
ICollection<T>The collection
items
IEnumerable<T>Items to be removed from the list
Type Parameters
T
Type of the items in the collection
RemoveAll<T>(ICollection<T>, Func<T, bool>)
Removes all items from the collection those satisfy the given predicate
.
public static IList<T> RemoveAll<T>(this ICollection<T> source, Func<T, bool> predicate)
Parameters
source
ICollection<T>The collection
predicate
Func<T, bool>The condition to remove the items
Returns
- IList<T>
List of removed items
Type Parameters
T
Type of the items in the collection