EnumerableExtensions
Assembly: ServiceStack.Common.dll
Declaration
public static class EnumerableExtensions
Methods
 IsEmpty<T>(ICollection<T>)
Declaration
public static bool IsEmpty<T>(this ICollection<T> collection)
Returns
System.Boolean
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.ICollection<<T>> | collection | 
Type Parameters
 IsEmpty<T>(T[])
Declaration
public static bool IsEmpty<T>(this T[] collection)
Returns
System.Boolean
Parameters
Type Parameters
 ToHashSet<T>(IEnumerable<T>)
Declaration
[Obsolete("Use ToSet() or 'using System.Linq;'")]
public static HashSet<T> ToHashSet<T>(this IEnumerable<T> items)
Returns
System.Collections.Generic.HashSet<<T>>
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.IEnumerable<<T>> | items | 
Type Parameters
 ToSet<T>(IEnumerable<T>)
Declaration
public static HashSet<T> ToSet<T>(this IEnumerable<T> items)
Returns
System.Collections.Generic.HashSet<<T>>
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.IEnumerable<<T>> | items | 
Type Parameters
 ToSet<T>(IEnumerable<T>, IEqualityComparer<T>)
Declaration
public static HashSet<T> ToSet<T>(this IEnumerable<T> items, IEqualityComparer<T> comparer)
Returns
System.Collections.Generic.HashSet<<T>>
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.IEnumerable<<T>> | items | 
| System.Collections.Generic.IEqualityComparer<<T>> | comparer | 
Type Parameters
 Each<T>(IEnumerable<T>, Action<T>)
Declaration
public static void Each<T>(this IEnumerable<T> values, Action<T> action)
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.IEnumerable<<T>> | values | 
| System.Action<<T>> | action | 
Type Parameters
 Each<T>(IEnumerable<T>, Action<Int32, T>)
Declaration
public static void Each<T>(this IEnumerable<T> values, Action<int, T> action)
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.IEnumerable<<T>> | values | 
| System.Action<System.Int32,<T>> | action | 
Type Parameters
 Each<TKey, TValue>(IDictionary<TKey, TValue>, Action<TKey, TValue>)
Declaration
public static void Each<TKey, TValue>(this IDictionary<TKey, TValue> map, Action<TKey, TValue> action)
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.IDictionary<<TKey>,<TValue>> | map | 
| System.Action<<TKey>,<TValue>> | action | 
Type Parameters
 Map<To, From>(IEnumerable<From>, Func<From, To>)
Declaration
public static List<To> Map<To, From>(this IEnumerable<From> items, Func<From, To> converter)
Returns
System.Collections.Generic.List<<To>>
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.IEnumerable<<From>> | items | 
| System.Func<<From>,<To>> | converter | 
Type Parameters
 Map<To>(IEnumerable, Func<Object, To>)
Declaration
public static List<To> Map<To>(this IEnumerable items, Func<object, To> converter)
Returns
System.Collections.Generic.List<<To>>
Parameters
| Type | Name | 
|---|
| System.Collections.IEnumerable | items | 
| System.Func<System.Object,<To>> | converter | 
Type Parameters
 ToObjects<T>(IEnumerable<T>)
Declaration
public static List<object> ToObjects<T>(this IEnumerable<T> items)
Returns
System.Collections.Generic.List<System.Object>
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.IEnumerable<<T>> | items | 
Type Parameters
 FirstNonDefaultOrEmpty(IEnumerable<String>)
Declaration
public static string FirstNonDefaultOrEmpty(this IEnumerable<string> values)
Returns
System.String
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.IEnumerable<System.String> | values | 
 FirstNonDefault<T>(IEnumerable<T>)
Declaration
public static T FirstNonDefault<T>(this IEnumerable<T> values)
Returns
<T>
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.IEnumerable<<T>> | values | 
Type Parameters
 EquivalentTo(Byte[], Byte[])
Declaration
public static bool EquivalentTo(this byte[] bytes, byte[] other)
Returns
System.Boolean
Parameters
| Type | Name | 
|---|
| System.Byte[] | bytes | 
| System.Byte[] | other | 
 EquivalentTo<T>(T[], T[], Func<T, T, Boolean>)
Declaration
public static bool EquivalentTo<T>(this T[] array, T[] otherArray, Func<T, T, bool> comparer = null)
Returns
System.Boolean
Parameters
| Type | Name | 
|---|
| <T>[] | array | 
| <T>[] | otherArray | 
| System.Func<<T>,<T>,System.Boolean> | comparer | 
Type Parameters
 EquivalentTo<T>(IEnumerable<T>, IEnumerable<T>, Func<T, T, Boolean>)
Declaration
public static bool EquivalentTo<T>(this IEnumerable<T> thisList, IEnumerable<T> otherList, Func<T, T, bool> comparer = null)
Returns
System.Boolean
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.IEnumerable<<T>> | thisList | 
| System.Collections.Generic.IEnumerable<<T>> | otherList | 
| System.Func<<T>,<T>,System.Boolean> | comparer | 
Type Parameters
 EquivalentTo<K, V>(IDictionary<K, V>, IDictionary<K, V>, Func<V, V, Boolean>)
Declaration
public static bool EquivalentTo<K, V>(this IDictionary<K, V> a, IDictionary<K, V> b, Func<V, V, bool> comparer = null)
Returns
System.Boolean
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.IDictionary<<K>,<V>> | a | 
| System.Collections.Generic.IDictionary<<K>,<V>> | b | 
| System.Func<<V>,<V>,System.Boolean> | comparer | 
Type Parameters
 BatchesOf<T>(IEnumerable<T>, Int32)
Declaration
public static IEnumerable<T[]> BatchesOf<T>(this IEnumerable<T> sequence, int batchSize)
Returns
System.Collections.Generic.IEnumerable<<T>[]>
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.IEnumerable<<T>> | sequence | 
| System.Int32 | batchSize | 
Type Parameters
 ToSafeDictionary<T, TKey>(IEnumerable<T>, Func<T, TKey>)
Declaration
public static Dictionary<TKey, T> ToSafeDictionary<T, TKey>(this IEnumerable<T> list, Func<T, TKey> expr)
Returns
System.Collections.Generic.Dictionary<<TKey>,<T>>
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.IEnumerable<<T>> | list | 
| System.Func<<T>,<TKey>> | expr | 
Type Parameters
 ToDictionary<T, TKey, TValue>(IEnumerable<T>, Func<T, KeyValuePair<TKey, TValue>>)
Declaration
public static Dictionary<TKey, TValue> ToDictionary<T, TKey, TValue>(this IEnumerable<T> list, Func<T, KeyValuePair<TKey, TValue>> map)
Returns
System.Collections.Generic.Dictionary<<TKey>,<TValue>>
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.IEnumerable<<T>> | list | 
| System.Func<<T>,System.Collections.Generic.KeyValuePair<<TKey>,<TValue>>> | map | 
Type Parameters
 Safe<T>(IEnumerable<T>)
Return T[0] when enumerable is null, safe to use in enumerations like foreach
Declaration
public static IEnumerable<T> Safe<T>(this IEnumerable<T> enumerable)
Returns
System.Collections.Generic.IEnumerable<<T>>
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.IEnumerable<<T>> | enumerable | 
Type Parameters
 Safe(IEnumerable)
Declaration
public static IEnumerable Safe(this IEnumerable enumerable)
Returns
System.Collections.IEnumerable
Parameters
| Type | Name | 
|---|
| System.Collections.IEnumerable | enumerable | 
 AllAsync<T>(IEnumerable<T>, Func<T, Task<Boolean>>)
Declaration
public static async Task<bool> AllAsync<T>(this IEnumerable<T> source, Func<T, Task<bool>> predicate)
Returns
System.Threading.Tasks.Task<System.Boolean>
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.IEnumerable<<T>> | source | 
| System.Func<<T>,System.Threading.Tasks.Task<System.Boolean>> | predicate | 
Type Parameters
 AllAsync<T>(IEnumerable<Task<T>>, Func<T, Boolean>)
Declaration
public static async Task<bool> AllAsync<T>(this IEnumerable<Task<T>> source, Func<T, bool> predicate)
Returns
System.Threading.Tasks.Task<System.Boolean>
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.IEnumerable<System.Threading.Tasks.Task<<T>>> | source | 
| System.Func<<T>,System.Boolean> | predicate | 
Type Parameters
 AnyAsync<T>(IEnumerable<T>, Func<T, Task<Boolean>>)
Declaration
public static async Task<bool> AnyAsync<T>(this IEnumerable<T> source, Func<T, Task<bool>> predicate)
Returns
System.Threading.Tasks.Task<System.Boolean>
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.IEnumerable<<T>> | source | 
| System.Func<<T>,System.Threading.Tasks.Task<System.Boolean>> | predicate | 
Type Parameters
 AnyAsync<T>(IEnumerable<Task<T>>, Func<T, Boolean>)
Declaration
public static async Task<bool> AnyAsync<T>(this IEnumerable<Task<T>> source, Func<T, bool> predicate)
Returns
System.Threading.Tasks.Task<System.Boolean>
Parameters
| Type | Name | 
|---|
| System.Collections.Generic.IEnumerable<System.Threading.Tasks.Task<<T>>> | source | 
| System.Func<<T>,System.Boolean> | predicate | 
Type Parameters
 AllKeysWithDefaultValues(IEnumerable)
Declaration
public static List<string> AllKeysWithDefaultValues(IEnumerable collection)
Returns
System.Collections.Generic.List<System.String>
Parameters
| Type | Name | 
|---|
| System.Collections.IEnumerable | collection | 
 FirstElementType(IEnumerable, String)
Declaration
public static Type FirstElementType(IEnumerable collection, string key)
Returns
System.Type
Parameters
| Type | Name | 
|---|
| System.Collections.IEnumerable | collection | 
| System.String | key | 
 CombineDistinct<T>(T[], T[][])
Declaration
public static T[] CombineDistinct<T>(this T[] original, params T[][] others)
Returns
<T>[]
Parameters
| Type | Name | 
|---|
| <T>[] | original | 
| <T>[][] | others | 
Type Parameters
 CombineSet<T>(T[], T[][])
Declaration
public static HashSet<T> CombineSet<T>(this T[] original, params T[][] others)
Returns
System.Collections.Generic.HashSet<<T>>
Parameters
| Type | Name | 
|---|
| <T>[] | original | 
| <T>[][] | others | 
Type Parameters