Show / Hide Table of Contents

    Class CollectionsExtensions

    Collections extension functions

    Inheritance
    Object
    CollectionsExtensions
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: XData.Extensions
    Assembly: XData.docfx.dll
    Syntax
    public static class CollectionsExtensions

    Methods

    | Improve this Doc View Source

    AsEnum<T>(T)

    Returns single item enumerable

    Declaration
    public static IEnumerable<T> AsEnum<T>(this T item)
    Parameters
    Type Name Description
    T item

    Item

    Returns
    Type Description
    IEnumerable<T>

    Single item enumerable

    Type Parameters
    Name Description
    T

    Item type

    | Improve this Doc View Source

    Clear<T>(List<T>, Action<T>)

    Clear list content with action call on every element

    Declaration
    public static void Clear<T>(this List<T> list, Action<T> action)
    Parameters
    Type Name Description
    List<T> list

    List

    Action<T> action

    Action

    Type Parameters
    Name Description
    T

    List element type

    | Improve this Doc View Source

    GetOrAdd<T>(IList<T>, Func<T, Boolean>, Func<T>)

    Returns first found element by predicate or add selector result and return it

    Declaration
    public static T GetOrAdd<T>(this IList<T> list, Func<T, bool> predicate, Func<T> selector)
    Parameters
    Type Name Description
    IList<T> list

    List

    Func<T, Boolean> predicate

    Find element predicate

    Func<T> selector

    Create element logic

    Returns
    Type Description
    T

    Found or crested element

    Type Parameters
    Name Description
    T

    Element type

    Exceptions
    Type Condition
    XDataRuntimeException

    Argument is null

    | Improve this Doc View Source

    HasSameValuesAs(ICollection<TaggedValue>, ICollection<TaggedValue>)

    Dictionary comparison test

    Declaration
    public static bool HasSameValuesAs(this ICollection<TaggedValue> source, ICollection<TaggedValue> other)
    Parameters
    Type Name Description
    ICollection<TaggedValue> source

    Source dictionary

    ICollection<TaggedValue> other

    Matched dictionary

    Returns
    Type Description
    Boolean
    | Improve this Doc View Source

    HasSameValuesAs<TKey, TValue>(ICollection<KeyValuePair<TKey, TValue>>, ICollection<KeyValuePair<TKey, TValue>>)

    Dictionary comparison test

    Declaration
    public static bool HasSameValuesAs<TKey, TValue>(this ICollection<KeyValuePair<TKey, TValue>> source, ICollection<KeyValuePair<TKey, TValue>> other)
        where TValue : IComparable
    Parameters
    Type Name Description
    ICollection<KeyValuePair<TKey, TValue>> source

    Source dictionary

    ICollection<KeyValuePair<TKey, TValue>> other

    Matched dictionary

    Returns
    Type Description
    Boolean
    Type Parameters
    Name Description
    TKey

    Type of dictionary key

    TValue

    Type of dictionary value

    | Improve this Doc View Source

    HasSameValuesAs<TKey, TValue>(IDictionary<TKey, TValue>, IDictionary<TKey, TValue>)

    Dictionary comparison test

    Declaration
    public static bool HasSameValuesAs<TKey, TValue>(this IDictionary<TKey, TValue> source, IDictionary<TKey, TValue> other)
        where TValue : IEquatable<TValue>
    Parameters
    Type Name Description
    IDictionary<TKey, TValue> source

    Source dictionary

    IDictionary<TKey, TValue> other

    Matched dictionary

    Returns
    Type Description
    Boolean
    Type Parameters
    Name Description
    TKey

    Type of dictionary key

    TValue

    Type of dictionary value

    | Improve this Doc View Source

    IsEmpty(ICollection<IComparable>)

    IComparable array IsEmpty helper

    Declaration
    public static bool IsEmpty(this ICollection<IComparable> fields)
    Parameters
    Type Name Description
    ICollection<IComparable> fields

    Array of values

    Returns
    Type Description
    Boolean

    Any of fields is null or DBNull

    | Improve this Doc View Source

    RemoveAll<TKey, TValue>(ConcurrentDictionary<TKey, TValue>, Func<TKey, Boolean>)

    Remove all elements matched predicate

    Declaration
    public static void RemoveAll<TKey, TValue>(this ConcurrentDictionary<TKey, TValue> collection, Func<TKey, bool> predicate)
    Parameters
    Type Name Description
    ConcurrentDictionary<TKey, TValue> collection

    Concurrent dictionary

    Func<TKey, Boolean> predicate

    Filtering predicate

    Type Parameters
    Name Description
    TKey

    Key type

    TValue

    Value type

    | Improve this Doc View Source

    SetValue<TKey, T>(TKey, T)

    Named value pair builder

    Declaration
    public static KeyValuePair<TKey, T> SetValue<TKey, T>(this TKey name, T value)
    Parameters
    Type Name Description
    TKey name

    Name

    T value

    Value

    Returns
    Type Description
    KeyValuePair<TKey, T>

    Named value pair

    Type Parameters
    Name Description
    TKey

    Key type

    T

    Value type

    | Improve this Doc View Source

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

    ToDictionary helper

    Declaration
    public static Dictionary<TKey, TValue> ToDictionary<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> pairs)
    Parameters
    Type Name Description
    IEnumerable<KeyValuePair<TKey, TValue>> pairs

    KeyValuePair collection

    Returns
    Type Description
    Dictionary<TKey, TValue>

    Typed Dictionary

    Type Parameters
    Name Description
    TKey

    Dictionary key type

    TValue

    Dictionary value type

    | Improve this Doc View Source

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

    ToDictionary groupings helper

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

    Groupings

    Returns
    Type Description
    Dictionary<TKey, List<TValue>>

    Typed Dictionary

    Type Parameters
    Name Description
    TKey

    Dictionary key type

    TValue

    Dictionary value type

    | Improve this Doc View Source

    ToSortedList<TKey, TValue>(IEnumerable<KeyValuePair<TKey, TValue>>)

    ToSortedList helper

    Declaration
    public static SortedList<TKey, TValue> ToSortedList<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> pairs)
        where TKey : IComparable
    Parameters
    Type Name Description
    IEnumerable<KeyValuePair<TKey, TValue>> pairs

    KeyValuePair collection

    Returns
    Type Description
    SortedList<TKey, TValue>

    Typed SortedList

    Type Parameters
    Name Description
    TKey

    Dictionary key type

    TValue

    Dictionary value type

    | Improve this Doc View Source

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

    ToSortedList groupings helper

    Declaration
    public static SortedList<TKey, List<TValue>> ToSortedList<TKey, TValue>(this IEnumerable<IGrouping<TKey, TValue>> groupings)
        where TKey : IComparable
    Parameters
    Type Name Description
    IEnumerable<IGrouping<TKey, TValue>> groupings

    Groupings

    Returns
    Type Description
    SortedList<TKey, List<TValue>>

    Typed SortedList

    Type Parameters
    Name Description
    TKey

    SortedList key type

    TValue

    SortedList value type

    | Improve this Doc View Source

    ToSortedSet<T>(IEnumerable<T>, IComparer<T>)

    ToSortedSet helper

    Declaration
    public static SortedSet<T> ToSortedSet<T>(this IEnumerable<T> source, IComparer<T> comparer = null)
    Parameters
    Type Name Description
    IEnumerable<T> source

    Source sequence

    IComparer<T> comparer

    Source type comparer

    Returns
    Type Description
    SortedSet<T>

    Typed SortedSet

    Type Parameters
    Name Description
    T

    SortedSet type

    Remarks

    If comparer is not set GetInstance() used

    WARNING! To use Indexer<T> one of IComparable<T> properties of source type mast be marked by IndexAttribute

    | Improve this Doc View Source

    TryGetValue<TKey, TValue>(IEnumerable<KeyValuePair<TKey, TValue>>, TKey)

    Try get value helper

    Declaration
    public static object TryGetValue<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> source, TKey key)
        where TKey : IEquatable<TKey>
    Parameters
    Type Name Description
    IEnumerable<KeyValuePair<TKey, TValue>> source

    Sequence of key value pairs

    TKey key

    Key value

    Returns
    Type Description
    Object
    Type Parameters
    Name Description
    TKey

    Key type

    TValue

    Value type

    • Improve this Doc
    • View Source
    Back to top Generated by DocFX