Show / Hide Table of Contents

Class IEnumerableTEx

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

Inheritance
System.Object
IEnumerableTEx
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 IEnumerableTEx

Methods

| Improve this Doc View Source

AnyAndNotNull<T>(IEnumerable<T>)

Checks if the given IEnumerable is not null and contains some items.

Declaration
public static bool AnyAndNotNull<T>(this IEnumerable<T> enumerable)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The IEnumerable to act on.

Returns
Type Description
System.Boolean

Returns true if the IEnumerable is not null or empty, otherwise false.

Type Parameters
Name Description
T The type of the items in the IEnumerable.
Examples
 
List<String> strings = null;
Console.WriteLine( strings.AnyAndNotNull() ); // False
strings = new List<String>();
Console.WriteLine( strings.AnyAndNotNull() ); // False
strings.AddRange( "1", "2", "3" );
Console.WriteLine( strings.AnyAndNotNull() ); // True
| Improve this Doc View Source

AnyAndNotNull<T>(IEnumerable<T>, Func<T, Boolean>)

Checks if the given IEnumerable is not null and contains some items which mates the given predicate.

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

The IEnumerable to act on.

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

The predicate.

Returns
Type Description
System.Boolean

Returns true if the IEnumerable is not null or empty, otherwise false.

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

The predicate can not be null.

| Improve this Doc View Source

Append<T>(IEnumerable<T>, T)

Appends the given item to the given sequence.

Declaration
public static IEnumerable<T> Append<T>(this IEnumerable<T> source, T item)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> source

The sequence to append an item to.

T item

The item to append.

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

The source sequence followed by the appended item.

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

source can not be null.

| Improve this Doc View Source

ContainsAll<T>(IEnumerable<T>, T[])

s Checks if the IEnumerable contains all given values.

Declaration
public static bool ContainsAll<T>(this IEnumerable<T> enumerable, params T[] values)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The IEnumerable to act on.

T[] values

The values to search for.

Returns
Type Description
System.Boolean

Returns true if the IEnumerable contains all given values, otherwise false.

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

The enumerable can not be null.

System.ArgumentNullException

The values can not be null.

| Improve this Doc View Source

ContainsAll<T>(IEnumerable<T>, IEnumerable<T>)

s Checks if the IEnumerable contains all values of the given IEnumerable.

Declaration
public static bool ContainsAll<T>(this IEnumerable<T> enumerable, IEnumerable<T> values)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The IEnumerable to act on.

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

The IEnumerable containing the values to search for.

Returns
Type Description
System.Boolean

Returns true if the IEnumerable contains all given values, otherwise false.

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

The enumerable can not be null.

System.ArgumentNullException

The values can not be null.

| Improve this Doc View Source

ContainsAny<T>(IEnumerable<T>, T[])

Checks if the IEnumerable contains any of the given values.

Declaration
public static bool ContainsAny<T>(this IEnumerable<T> enumerable, params T[] values)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The IEnumerable to act on.

T[] values

The values to search for.

Returns
Type Description
System.Boolean

Returns true if the IEnumerable contains any of the given values, otherwise false.

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

The enumerable can not be null.

System.ArgumentNullException

The values can not be null.

| Improve this Doc View Source

ContainsAny<T>(IEnumerable<T>, IEnumerable<T>)

Checks if the IEnumerable contains any of the values of the given IEnumerable.

Declaration
public static bool ContainsAny<T>(this IEnumerable<T> enumerable, IEnumerable<T> values)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The IEnumerable to act on.

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

The IEnumerable containing the values to search for.

Returns
Type Description
System.Boolean

Returns true if the IEnumerable contains any of the values of the given IEnumerable, otherwise false.

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

The enumerable can not be null.

System.ArgumentNullException

The values can not be null.

| Improve this Doc View Source

Distinct<T, TKey>(IEnumerable<T>, Func<T, TKey>)

Returns all unique items, based on the given predicate.

Declaration
public static IEnumerable<T> Distinct<T, TKey>(this IEnumerable<T> enumerable, Func<T, TKey> predicate)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The IEnumerable.

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

The Predicate.

Returns
Type Description
System.Collections.Generic.IEnumerable<T><T>
Type Parameters
Name Description
T The type of the items in the IEnumerable.
TKey The input type of the predicate.
Exceptions
Type Condition
System.ArgumentNullException

The enumerable can not be null.

System.ArgumentNullException

The predicate can not be null.

| Improve this Doc View Source

EnsureNotNull<T>(IEnumerable<T>)

Ensures that the given System.Collections.Generic.IEnumerable<T> is not null.

Declaration
public static IEnumerable<T> EnsureNotNull<T>(this IEnumerable<T> enumerable)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The IEnumerable.

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

Returns the given IEnumerable if it's not null, otherwise an empty array of type T.

Type Parameters
Name Description
T The type of the items in the IEnumerable.
| Improve this Doc View Source

Except<TSource, TKey>(IEnumerable<TSource>, IEnumerable<TSource>, Func<TSource, TKey>, IEqualityComparer<TKey>)

Produces the set difference of two sequences by using the specified

System.Collections.Generic.IEqualityComparer<T> to compare values.

Declaration
public static IEnumerable<TSource> Except<TSource, TKey>(this IEnumerable<TSource> first, IEnumerable<TSource> second, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer = null)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><TSource> first

An System.Collections.Generic.IEnumerable<T> whose elements that are not also in second will be returned.

System.Collections.Generic.IEnumerable<T><TSource> second

An System.Collections.Generic.IEnumerable<T> whose elements that also occur in the first sequence will cause those elements to be removed from the returned sequence.

System.Func<T, TResult><TSource, TKey> keySelector

A function used to select the key of the items to compare.

System.Collections.Generic.IEqualityComparer<T><TKey> comparer

An optional System.Collections.Generic.IEqualityComparer<T> to compare the keys of the items.

Returns
Type Description
System.Collections.Generic.IEnumerable<T><TSource>

A sequence that contains the set difference of the elements of two sequences.

Type Parameters
Name Description
TSource The type of the items to compare.
TKey The type of the item keys.
Exceptions
Type Condition
System.ArgumentNullException

first can not be null.

System.ArgumentNullException

second can not be null.

System.ArgumentNullException

keySelector can not be null.

| Improve this Doc View Source

ForEach<T>(IEnumerable<T>, Action<T, Int32>)

Performs the specified action on each object in the given enumerable.

Declaration
public static IEnumerable<T> ForEach<T>(this IEnumerable<T> enumerable, Action<T, int> action)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The enumerable containing all the items.

System.Action<T1, T2><T, System.Int32> action

The action to perform on each item of the given enumerable. The action takes a item of the given enumerable and it's index as parameter.

Returns
Type Description
System.Collections.Generic.IEnumerable<T><T>
Type Parameters
Name Description
T The type of the items in the given enumerable.
Exceptions
Type Condition
System.ArgumentNullException

The source collection can not be null.

System.ArgumentNullException

The action can not be null.

| Improve this Doc View Source

ForEach<T>(IEnumerable<T>, Action<T>)

Performs the specified action on each object in the given enumerable.

Declaration
public static IEnumerable<T> ForEach<T>(this IEnumerable<T> enumerable, Action<T> action)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The enumerable containing all the items.

System.Action<T><T> action

The action to perform on each item of the given enumerable.

Returns
Type Description
System.Collections.Generic.IEnumerable<T><T>
Type Parameters
Name Description
T The type of the items in the given enumerable.
Exceptions
Type Condition
System.ArgumentNullException

The source collection can not be null.

System.ArgumentNullException

The action can not be null.

| Improve this Doc View Source

ForEachReverse<T>(IEnumerable<T>, Action<T>)

Executes the given action for each item in the IEnumerable in a reversed order.

Declaration
public static IEnumerable<T> ForEachReverse<T>(this IEnumerable<T> enumerable, Action<T> action)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The IEnumerable to act on.

System.Action<T><T> action

The action to execute for each item in the IEnumerable.

Returns
Type Description
System.Collections.Generic.IEnumerable<T><T>
Type Parameters
Name Description
T
Remarks

It's save to remove items from the IEnumerable within the loop.

Exceptions
Type Condition
System.ArgumentNullException

The enumerable can not be null.

System.ArgumentNullException

The action can not be null.

| Improve this Doc View Source

GetEqualItemsFromStart<T>(IEnumerable<T>, IEnumerable<T>, IEqualityComparer<T>)

Returns the equal items of two IEnumerables, according to the specified comparer. Beginning at the start of the IEnumerables, ending when first different item is found.

Declaration
public static IEnumerable<T> GetEqualItemsFromStart<T>(this IEnumerable<T> left, IEnumerable<T> right, IEqualityComparer<T> comparer = null)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> left

The first IEnumerable.

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

The second IEnumerable.

System.Collections.Generic.IEqualityComparer<T><T> comparer

The comparer used to test items for equality.

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

A sequence consisting of the first elements of left that match the first elements of right. The resulting sequence ends when the two input sequence start to differ.

Type Parameters
Name Description
T The type of the items in the IEnumerable.
| Improve this Doc View Source

GetRandomItem<T>(IEnumerable<T>)

Gets a random item form the given IEnumerable.

Declaration
public static T GetRandomItem<T>(this IEnumerable<T> enumerable)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The IEnumerable.

Returns
Type Description
T

Returns an random item of the given IEnumerable.

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

The enumerable can not be null.

| Improve this Doc View Source

Intersect<TSource, TKey>(IEnumerable<TSource>, IEnumerable<TSource>, Func<TSource, TKey>, IEqualityComparer<TKey>)

Produces the set intersection of two sequences.

Declaration
public static IEnumerable<TSource> Intersect<TSource, TKey>(this IEnumerable<TSource> first, IEnumerable<TSource> second, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer = null)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><TSource> first

An System.Collections.Generic.IEnumerable<T> whose distinct elements that also appear in second will be returned.

System.Collections.Generic.IEnumerable<T><TSource> second

An System.Collections.Generic.IEnumerable<T> whose distinct elements that also appear in the first sequence will be returned.

System.Func<T, TResult><TSource, TKey> keySelector

A function used to select the key of the items to compare.

System.Collections.Generic.IEqualityComparer<T><TKey> comparer

An optional System.Collections.Generic.IEqualityComparer<T> to compare the keys of the items.

Returns
Type Description
System.Collections.Generic.IEnumerable<T><TSource>

Returns a sequence that contains the elements that form the set intersection of two sequences.

Type Parameters
Name Description
TSource The type of the items to compare.
TKey The type of the item keys.
Exceptions
Type Condition
System.ArgumentNullException

first can not be null.

System.ArgumentNullException

second can not be null.

System.ArgumentNullException

keySelector can not be null.

| Improve this Doc View Source

IsNullOrEmpty<T>(IEnumerable<T>)

Checks if the enumerable is empty or null.

Declaration
public static bool IsNullOrEmpty<T>(this IEnumerable<T> enumerable)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The enumerable to check.

Returns
Type Description
System.Boolean

Returns true if the enumerable is empty or null, otherwise false.

Type Parameters
Name Description
T The type of the items in the enumerable.
| Improve this Doc View Source

Many<T>(IEnumerable<T>)

Gets whether the IEnumerable contains more than one item.

Declaration
public static bool Many<T>(this IEnumerable<T> enumerable)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The IEnumerable.

Returns
Type Description
System.Boolean

Returns true if the IEnumerable contains more than one item, otherwise false.

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

The enumerable can not be null.

| Improve this Doc View Source

Many<T>(IEnumerable<T>, Func<T, Boolean>)

Gets whether the IEnumerable contains more than one item matching the given predicate.

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

The IEnumerable.

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

The predicate.

Returns
Type Description
System.Boolean

Returns true if the IEnumerable contains more than one item matching the given predicate, otherwise false.

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

The enumerable can not be null.

System.ArgumentNullException

The predicate can not be null.

| Improve this Doc View Source

MinimumOf<T>(IEnumerable<T>, Int32)

Gets whether the IEnumerable contains at least the specified number of items.

Declaration
public static bool MinimumOf<T>(this IEnumerable<T> enumerable, int count)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The IEnumerable.

System.Int32 count

The minimum number of items.

Returns
Type Description
System.Boolean

Returns true if the IEnumerable contains at least the specified number of items, otherwise false.

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

The enumerable can not be null.

| Improve this Doc View Source

MinimumOf<T>(IEnumerable<T>, Int32, Func<T, Boolean>)

Gets whether the IEnumerable contains at least the specified number of items matching the specified predicate.

Declaration
public static bool MinimumOf<T>(this IEnumerable<T> enumerable, int count, Func<T, bool> predicate)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The IEnumerable.

System.Int32 count

The minimum number of items.

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

The predicate.

Returns
Type Description
System.Boolean

Returns true if the IEnumerable contains at least the specified number of items matching the specified predicate, otherwise false.

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

The enumerable can not be null.

System.ArgumentNullException

The predicate can not be null.

| Improve this Doc View Source

NotAny<T>(IEnumerable<T>)

Determines whether the given IEnumerable contains no items, or not.

Declaration
public static bool NotAny<T>(this IEnumerable<T> enumerable)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The IEnumerable to check.

Returns
Type Description
System.Boolean

Returns true if the IEnumerable doesn't contain any items, otherwise false.

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

The enumerable can not be null.

| Improve this Doc View Source

NotAny<T>(IEnumerable<T>, Func<T, Boolean>)

Determines whether the given IEnumerable contains no items matching the given predicate, or not.

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

The IEnumerable to check.

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

The predicate.

Returns
Type Description
System.Boolean

Returns true if the IEnumerable doesn't contain any items, otherwise false.

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

The enumerable can not be null.

System.ArgumentNullException

The predicate can not be null.

| Improve this Doc View Source

Partition<T>(IEnumerable<T>, Int32)

Partitions the given sequence into blocks with the specified size.

Declaration
public static IEnumerable<IEnumerable<T>> Partition<T>(this IEnumerable<T> source, int size)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> source

The sequence to partition.

System.Int32 size

The number of items per block.

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

Returns the created blocks.

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

source can not be null.

System.ArgumentOutOfRangeException

size is smaller than 1.

| Improve this Doc View Source

Prepend<T>(IEnumerable<T>, T)

Prepends the given item to the given sequence.

Declaration
public static IEnumerable<T> Prepend<T>(this IEnumerable<T> source, T item)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> source

The sequence to prepend an item to.

T item

The item to prepend.

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

The source sequence preceded by the prepended item.

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

source can not be null.

| Improve this Doc View Source

Randomize<T>(IEnumerable<T>)

Orders the items in the IEnumerable randomly.

Declaration
public static IEnumerable<T> Randomize<T>(this IEnumerable<T> enumerable)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The IEnumerable.

Returns
Type Description
System.Collections.Generic.IEnumerable<T><T>
Type Parameters
Name Description
T The type of the items in the enumerable.
Exceptions
Type Condition
System.ArgumentNullException

The enumerable can not be null.

| Improve this Doc View Source

SpecificationForItems<T>(IEnumerable<T>, Func<T, Boolean>, String)

Creates a specification with the given condition and message.

Declaration
public static ISpecification<T> SpecificationForItems<T>(this IEnumerable<T> enumerable, Func<T, bool> expression, string message = null)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The enumerable to create the expression on.

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

An expression determining whether an object matches the specification or not.

System.String message

An error messaged, returned when an object doesn't match the specification.

Returns
Type Description
ISpecification<T><T>

Returns a specification with the given condition and message.

Type Parameters
Name Description
T The target type of the expression.
Exceptions
Type Condition
System.ArgumentNullException

expression can not be null.

| Improve this Doc View Source

StringJoin<T>(IEnumerable<T>, Func<T, String>, String)

Concatenates all the elements of a IEnumerable, using the specified separator between each element.

Declaration
public static string StringJoin<T>(this IEnumerable<T> enumerable, Func<T, string> selector, string separator = "")
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

An IEnumerable that contains the elements to concatenate.

System.Func<T, TResult><T, System.String> selector

A transform function to apply to each element.

System.String separator

The string to use as a separator. The separator is included in the returned string only if the given IEnumerable has more than one item.

Returns
Type Description
System.String

A string that consists of the elements in the IEnumerable delimited by the separator string. If the given IEnumerable is empty, the method returns String.Empty.

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

The enumerable can not be null.

| Improve this Doc View Source

StringJoin<T>(IEnumerable<T>, String)

Concatenates all the elements of a IEnumerable, using the specified separator between each element.

Declaration
public static string StringJoin<T>(this IEnumerable<T> enumerable, string separator = "")
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

An IEnumerable that contains the elements to concatenate.

System.String separator

The string to use as a separator. The separator is included in the returned string only if the given IEnumerable has more than one item.

Returns
Type Description
System.String

A string that consists of the elements in the IEnumerable delimited by the separator string. If the given IEnumerable is empty, the method returns String.Empty.

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

The enumerable can not be null.

| Improve this Doc View Source

TakeUntil<T>(IEnumerable<T>, Func<T, Boolean>)

Takes items from the given IEnumerable until the first item matches the specified predicate.

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

The IEnumerable.

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

The predicate.

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

Returns the items from the start of the IEnumerable until the first item matching the predicate.

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

The enumerable can not be null.

System.ArgumentNullException

The predicate can not be null.

| Improve this Doc View Source

ToDictionary<TKey, TValue>(IEnumerable<IGrouping<TKey, TValue>>)

Converts the IEnumerable containing the groupings into a Dictionary of those groupings.

Declaration
public static Dictionary<TKey, List<TValue>> ToDictionary<TKey, TValue>(this IEnumerable<IGrouping<TKey, TValue>> groupings)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><<TKey, TValue>> groupings

The enumeration of groupings from a GroupBy() clause.

Returns
Type Description
System.Collections.Generic.Dictionary<TKey, TValue><TKey, System.Collections.Generic.List<T><TValue>>

Returns a dictionary of groupings such that the key of the dictionary is TKey type and the value is List of TValue type.

Type Parameters
Name Description
TKey The type of the key.
TValue The type of the items.
Exceptions
Type Condition
System.ArgumentNullException

The groupings can not be null.

| Improve this Doc View Source

ToObservableCollection<T>(IEnumerable<T>)

Converts the given IEnumerable to a ObservableCollection.

Declaration
public static ObservableCollection<T> ToObservableCollection<T>(this IEnumerable<T> enumerable)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The IEnumerable.

Returns
Type Description
System.Collections.ObjectModel.ObservableCollection<T><T>

The given IEnumerable as ObservableCollection.

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

The enumerable can not be null.

| Improve this Doc View Source

Where<T>(IEnumerable<T>, ISpecification<T>)

Returns all items of the given enumerable which satisfy the given specification.

Declaration
public static IEnumerable<T> Where<T>(this IEnumerable<T> enumerable, ISpecification<T> specification)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The enumerable.

ISpecification<T><T> specification

The specification.

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

Returns the items which satisfy the given specification.

Type Parameters
Name Description
T The type of the item in the enumerable.
Exceptions
Type Condition
System.ArgumentNullException

enumerable can not be null.

System.ArgumentNullException

specification can not be null.

| Improve this Doc View Source

WhereIf<T>(IEnumerable<T>, Boolean, Func<T, Boolean>)

Performs a where predicate on the IEnumerable, if the given condition is true, otherwise returns all items of the IEnumerable.

Declaration
public static IEnumerable<T> WhereIf<T>(this IEnumerable<T> source, bool condition, Func<T, bool> predicate)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> source

The IEnumerable containing the items.

System.Boolean condition

The condition determining whether the where predicate gets applied or not.

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

The where predicate.

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

Returns the result of the predicate if the condition is true, otherwise the source IEnumerable.

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

The source can not be null.

System.ArgumentNullException

The predicate can not be null.

| Improve this Doc View Source

WhereIf<T>(IEnumerable<T>, Boolean, Func<T, Int32, Boolean>)

Performs a where predicate on the IEnumerable, if the given condition is true, otherwise returns all items of the IEnumerable.

Declaration
public static IEnumerable<T> WhereIf<T>(this IEnumerable<T> source, bool condition, Func<T, int, bool> predicate)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> source

The IEnumerable containing the items.

System.Boolean condition

The condition determining whether the where predicate gets applied or not.

System.Func<T1, T2, TResult><T, System.Int32, System.Boolean> predicate

The where predicate.

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

Returns the result of the predicate if the condition is true, otherwise the source IEnumerable.

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

The source can not be null.

System.ArgumentNullException

The predicate can not be null.

| Improve this Doc View Source

WhereNot<T>(IEnumerable<T>, ISpecification<T>)

Returns all items of the given enumerable which doesn't satisfy the given specification.

Declaration
public static IEnumerable<T> WhereNot<T>(this IEnumerable<T> enumerable, ISpecification<T> specification)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> enumerable

The enumerable.

ISpecification<T><T> specification

The specification.

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

Returns the items which doesn't satisfy the given specification.

Type Parameters
Name Description
T The type of the item in the enumerable.
Exceptions
Type Condition
System.ArgumentNullException

enumerable can not be null.

System.ArgumentNullException

specification can not be null.

| Improve this Doc View Source

WithIndex<T>(IEnumerable<T>)

Associates an index to each element of the source IEnumerable.

Declaration
public static IEnumerable<IIndexedItem<T>> WithIndex<T>(this IEnumerable<T> source)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><T> source

The source IEnumerable.

Returns
Type Description
System.Collections.Generic.IEnumerable<T><IIndexedItem<T><T>>

A sequence of elements paired with their index in the sequence.

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

source can not be null.

| Improve this Doc View Source

WithoutIndex<T>(IEnumerable<IIndexedItem<T>>)

Removes the indexes from a IEnumerable of indexed elements, returning only the elements themselves.

Declaration
public static IEnumerable<T> WithoutIndex<T>(this IEnumerable<IIndexedItem<T>> source)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T><IIndexedItem<T><T>> source

The IEnumerable to remove the indexes from.

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

A IEnumerable of elements without their associated indexes.

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

source can not be null.

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