Show / Hide Table of Contents

Class AbpCollectionExtensions

Extension methods for Collections.

Inheritance
System.Object
AbpCollectionExtensions
Namespace: System.Collections.Generic
Assembly: Volo.Abp.Core.dll
Syntax
public static class AbpCollectionExtensions : object

Methods

AddIfNotContains<T>(ICollection<T>, T)

Adds an item to the collection if it's not already in the collection.

Declaration
public static bool AddIfNotContains<T>(this ICollection<T> source, T item)
Parameters
Type Name Description
ICollection<T> source

The collection

T item

Item to check and add

Returns
Type Description
System.Boolean

Returns True if added, returns False if not.

Type Parameters
Name Description
T

Type of the items in the collection

AddIfNotContains<T>(ICollection<T>, Func<T, Boolean>, Func<T>)

Adds an item to the collection if it's not already in the collection based on the given predicate.

Declaration
public static bool AddIfNotContains<T>(this ICollection<T> source, Func<T, bool> predicate, Func<T> itemFactory)
Parameters
Type Name Description
ICollection<T> source

The collection

Func<T, System.Boolean> predicate

The condition to decide if the item is already in the collection

Func<T> itemFactory

A factory that returns the item

Returns
Type Description
System.Boolean

Returns True if added, returns False if not.

Type Parameters
Name Description
T

Type of the items in the collection

AddIfNotContains<T>(ICollection<T>, IEnumerable<T>)

Adds items to the collection which are not already in the collection.

Declaration
public static IEnumerable<T> AddIfNotContains<T>(this ICollection<T> source, IEnumerable<T> items)
Parameters
Type Name Description
ICollection<T> source

The collection

IEnumerable<T> items

Item to check and add

Returns
Type Description
IEnumerable<T>

Returns the added items.

Type Parameters
Name Description
T

Type of the items in the collection

IsNullOrEmpty<T>(ICollection<T>)

Checks whatever given collection object is null or has no item.

Declaration
public static bool IsNullOrEmpty<T>(this ICollection<T> source)
Parameters
Type Name Description
ICollection<T> source
Returns
Type Description
System.Boolean
Type Parameters
Name Description
T

RemoveAll<T>(ICollection<T>, Func<T, Boolean>)

Removes all items from the collection those satisfy the given predicate.

Declaration
public static IList<T> RemoveAll<T>(this ICollection<T> source, Func<T, bool> predicate)
Parameters
Type Name Description
ICollection<T> source

The collection

Func<T, System.Boolean> predicate

The condition to remove the items

Returns
Type Description
IList<T>

List of removed items

Type Parameters
Name Description
T

Type of the items in the collection

Back to top Powered by Volosoft