Show / Hide Table of Contents

Class CollectionTEx

Class containing some extension methods for System.Collections.Generic.ICollection<T>.

Inheritance
System.Object
CollectionTEx
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace:Extend
Assembly:Extend.dll
Syntax
public static class CollectionTEx

Methods

| Improve this Doc View Source

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

Adds the specified value to the given value it satisfies the predicated provided.

Declaration
public static bool AddIf<T>(this ICollection<T> collection, Func<T, bool> predicate, T value)
Parameters
Type Name Description
System.Collections.Generic.ICollection<T><T> collection

The collection to which the item should get added.

System.Func<T, TResult><T, System.Boolean> predicate

The predicate.

T value

The value to add.

Returns
Type Description
System.Boolean

True if the value was added to the collection, otherwise false.

Type Parameters
Name Description
T The type of the items in the given collection..
Exceptions
Type Condition
System.ArgumentNullException

The collection can not be null.

System.ArgumentNullException

The predicate can not be null.

| Improve this Doc View Source

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

Adds the given value to the collection if the collection doesn't contains it already.

Declaration
public static bool AddIfNotContains<T>(this ICollection<T> collection, T value)
Parameters
Type Name Description
System.Collections.Generic.ICollection<T><T> collection

The collection to which the item should get added.

T value

The value. to add

Returns
Type Description
System.Boolean

True if the value was added to the collection, otherwise false.

Type Parameters
Name Description
T The type of the items in the collection.
Exceptions
Type Condition
System.ArgumentNullException

The collection can not be null.

| Improve this Doc View Source

AddRange<T>(ICollection<T>, T[])

Adds the given range of values to the collection.

Declaration
public static ICollection<T> AddRange<T>(this ICollection<T> collection, params T[] values)
Parameters
Type Name Description
System.Collections.Generic.ICollection<T><T> collection

The collection to which the values should get added.

T[] values

The values to add.

Returns
Type Description
System.Collections.Generic.ICollection<T><T>

Returns the given collection.

Type Parameters
Name Description
T The type of the items in the collection.
Exceptions
Type Condition
System.ArgumentNullException

The collection can not be null.

System.ArgumentNullException

The values can not be null.

| Improve this Doc View Source

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

Adds the items of the given IEnumerable to the collection.

Declaration
public static ICollection<T> AddRange<T>(this ICollection<T> collection, IEnumerable<T> enumerable)
Parameters
Type Name Description
System.Collections.Generic.ICollection<T><T> collection

The collection to which the values should get added.

System.Collections.Generic.IEnumerable<T><T> enumerable

The IEnumerable containing the items.

Returns
Type Description
System.Collections.Generic.ICollection<T><T>

Returns the given collection.

Type Parameters
Name Description
T The type of the items in the collection.
Exceptions
Type Condition
System.ArgumentNullException

The collection can not be null.

System.ArgumentNullException

The enumerable can not be null.

| Improve this Doc View Source

AddRangeIf<T>(ICollection<T>, Func<T, Boolean>, T[])

Adds all given values who satisfies the predicate to the collection.

Declaration
public static ICollection<T> AddRangeIf<T>(this ICollection<T> collection, Func<T, bool> predicate, params T[] values)
Parameters
Type Name Description
System.Collections.Generic.ICollection<T><T> collection

The collection to which the values should get added.

System.Func<T, TResult><T, System.Boolean> predicate

The predicate.

T[] values

The values to add.

Returns
Type Description
System.Collections.Generic.ICollection<T><T>

Returns the given collection.

Type Parameters
Name Description
T The type of the items in the collection.
Exceptions
Type Condition
System.ArgumentNullException

collection can not be null.

System.ArgumentNullException

predicate can not be null.

System.ArgumentNullException

values can not be null.

| Improve this Doc View Source

AddRangeIf<T>(ICollection<T>, Func<T, Boolean>, IEnumerable<T>)

Adds all items of the given IEnumerable who satisfies the predicate to the collection.

Declaration
public static ICollection<T> AddRangeIf<T>(this ICollection<T> collection, Func<T, bool> predicate, IEnumerable<T> enumerable)
Parameters
Type Name Description
System.Collections.Generic.ICollection<T><T> collection

The collection to which the values should get added.

System.Func<T, TResult><T, System.Boolean> predicate

The predicate.

System.Collections.Generic.IEnumerable<T><T> enumerable

The IEnumerable containing the items.

Returns
Type Description
System.Collections.Generic.ICollection<T><T>

Returns the given collection.

Type Parameters
Name Description
T The type of the items in the collection.
Exceptions
Type Condition
System.ArgumentNullException

collection can not be null.

System.ArgumentNullException

predicate can not be null.

System.ArgumentNullException

enumerable can not be null.

| Improve this Doc View Source

AddRangeIfNotContains<T>(ICollection<T>, T[])

Adds the given values to the collection, if it not already contains it.

Declaration
public static ICollection<T> AddRangeIfNotContains<T>(this ICollection<T> collection, params T[] values)
Parameters
Type Name Description
System.Collections.Generic.ICollection<T><T> collection

The collection to which the values should get added.

T[] values

The values to add.

Returns
Type Description
System.Collections.Generic.ICollection<T><T>

Returns the given collection.

Type Parameters
Name Description
T The type of the items in the collection.
Exceptions
Type Condition
System.ArgumentNullException

collection can not be null.

System.ArgumentNullException

values can not be null.

| Improve this Doc View Source

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

Adds all items of the given IEnumerable to the collection, if it not already contains it.

Declaration
public static ICollection<T> AddRangeIfNotContains<T>(this ICollection<T> collection, IEnumerable<T> enumerable)
Parameters
Type Name Description
System.Collections.Generic.ICollection<T><T> collection

The collection to which the values should get added.

System.Collections.Generic.IEnumerable<T><T> enumerable

The IEnumerable containing the items.

Returns
Type Description
System.Collections.Generic.ICollection<T><T>

Returns the given collection.

Type Parameters
Name Description
T The type of the items in the collection.
Exceptions
Type Condition
System.ArgumentNullException

The collection can not be null.

System.ArgumentNullException

The enumerable can not be null.

| Improve this Doc View Source

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

Removes the given value from the collection, if it matches the predicate.

Declaration
public static ICollection<T> RemoveIf<T>(this ICollection<T> collection, T value, Func<T, bool> predicate)
Parameters
Type Name Description
System.Collections.Generic.ICollection<T><T> collection

The collection to act on.

T value

The value to remove.

System.Func<T, TResult><T, System.Boolean> predicate

The predicate.

Returns
Type Description
System.Collections.Generic.ICollection<T><T>

Returns the given collection.

Type Parameters
Name Description
T The type of the items in the collection.
Exceptions
Type Condition
System.ArgumentNullException

collection can not be null.

System.ArgumentNullException

predicate can not be null.

| Improve this Doc View Source

RemoveRange<T>(ICollection<T>, T[])

Removes the given values from the collection.

Declaration
public static ICollection<T> RemoveRange<T>(this ICollection<T> collection, params T[] values)
Parameters
Type Name Description
System.Collections.Generic.ICollection<T><T> collection

The collection, from which the values should get removed.

T[] values

The values to remove.

Returns
Type Description
System.Collections.Generic.ICollection<T><T>

Returns the given collection.

Type Parameters
Name Description
T The type of the items in the collection.
Exceptions
Type Condition
System.ArgumentNullException

The collection can not be null.

System.ArgumentNullException

The values can not be null.

| Improve this Doc View Source

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

Removes the given values from the collection.

Declaration
public static ICollection<T> RemoveRange<T>(this ICollection<T> collection, IEnumerable<T> enumerable)
Parameters
Type Name Description
System.Collections.Generic.ICollection<T><T> collection

The collection, from which the values should get removed.

System.Collections.Generic.IEnumerable<T><T> enumerable

A IEnumerable containing the items to remove from the collection.

Returns
Type Description
System.Collections.Generic.ICollection<T><T>

Returns the given collection.

Type Parameters
Name Description
T The type of the items in the collection.
Exceptions
Type Condition
System.ArgumentNullException

The collection can not be null.

System.ArgumentNullException

The enumerable can not be null.

| Improve this Doc View Source

RemoveRangeIf<T>(ICollection<T>, Func<T, Boolean>, T[])

Removes the given values that satisfy the predicate from the collection.

Declaration
public static ICollection<T> RemoveRangeIf<T>(this ICollection<T> collection, Func<T, bool> predicate, params T[] values)
Parameters
Type Name Description
System.Collections.Generic.ICollection<T><T> collection

The collection, from which the values should get removed.

System.Func<T, TResult><T, System.Boolean> predicate

The predicate.

T[] values

The values to remove.

Returns
Type Description
System.Collections.Generic.ICollection<T><T>

Returns the given collection.

Type Parameters
Name Description
T The type of the items in the collection.
Exceptions
Type Condition
System.ArgumentNullException

collection can not be null.

System.ArgumentNullException

predicate can not be null.

System.ArgumentNullException

values can not be null.

| Improve this Doc View Source

RemoveRangeIf<T>(ICollection<T>, Func<T, Boolean>, IEnumerable<T>)

Removes the items of the given IEnumerable that satisfy the predicate from the collection.

Declaration
public static ICollection<T> RemoveRangeIf<T>(this ICollection<T> collection, Func<T, bool> predicate, IEnumerable<T> enumerable)
Parameters
Type Name Description
System.Collections.Generic.ICollection<T><T> collection

The collection, from which the values should get removed.

System.Func<T, TResult><T, System.Boolean> predicate

The predicate.

System.Collections.Generic.IEnumerable<T><T> enumerable

A IEnumerable containing the items to remove from the collection.

Returns
Type Description
System.Collections.Generic.ICollection<T><T>

Returns the given collection.

Type Parameters
Name Description
T The type of the items in the collection.
Exceptions
Type Condition
System.ArgumentNullException

collection can not be null.

System.ArgumentNullException

predicate can not be null.

System.ArgumentNullException

enumerable can not be null.

  • Improve this Doc
  • View Source
Back to top Copyright © 2015-2016 Microsoft
Generated by DocFX