Show / Hide Table of Contents

    Class CollectionUtils

    Collection Utilities

    Inheritance
    Object
    CollectionUtils
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Microsoft.Graph.Communications.Common
    Assembly: Microsoft.Graph.Communications.Common.dll
    Syntax
    public static class CollectionUtils

    Methods

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

    Adds the range of source values into target.

    Declaration
    public static void AddRange<T>(this ICollection<T> target, IEnumerable<T> source)
    Parameters
    Type Name Description
    ICollection<T> target

    The target.

    IEnumerable<T> source

    The source.

    Type Parameters
    Name Description
    T

    The type of Collection

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

    Analogous to IList.ForEach but for IEnumerable

    Declaration
    public static void ForEach<T>(this IEnumerable<T> enumerable, Action<T> action)
    Parameters
    Type Name Description
    IEnumerable<T> enumerable

    Enumeration

    Action<T> action

    Action to invoke on each element

    Type Parameters
    Name Description
    T

    Element type.

    ForEachParallel<T>(IEnumerable<T>, Action<T>, IGraphLogger)

    Analogous to IList.ForEach but for IEnumerable

    Declaration
    public static Exception ForEachParallel<T>(this IEnumerable<T> enumerable, Action<T> action, IGraphLogger logger)
    Parameters
    Type Name Description
    IEnumerable<T> enumerable

    Enumeration

    Action<T> action

    Action to invoke on each element

    IGraphLogger logger

    Instance of the Logger

    Returns
    Type Description
    Exception

    Exception if any.

    Type Parameters
    Name Description
    T

    Element type

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

    Get Value or default

    Declaration
    public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key)
    Parameters
    Type Name Description
    IDictionary<TKey, TValue> dictionary

    Dictionary instance

    TKey key

    Key to lookup

    Returns
    Type Description
    TValue

    Value from dictionary or default value.

    Type Parameters
    Name Description
    TKey

    Type of the key

    TValue

    Type of the value

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

    Get Value or default

    Declaration
    public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue defaultValue)
    Parameters
    Type Name Description
    IDictionary<TKey, TValue> dictionary

    Dictionary instance

    TKey key

    Key to lookup

    TValue defaultValue

    The default value to be returned if it doesn't exist.

    Returns
    Type Description
    TValue

    Value from dictionary or default value.

    Type Parameters
    Name Description
    TKey

    Type of the key

    TValue

    Type of the value

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

    Converts sequence to a sorted list.

    Declaration
    public static SortedList<TKey, TValue> ToSortedList<TKey, TValue>(this IEnumerable<TValue> sequence, Func<TValue, TKey> keySelector)
    Parameters
    Type Name Description
    IEnumerable<TValue> sequence

    The sequence.

    Func<TValue, TKey> keySelector

    The function selector which provides a key given the value.

    Returns
    Type Description
    SortedList<TKey, TValue>

    Sorted list.

    Type Parameters
    Name Description
    TKey

    The type of the key.

    TValue

    The type of the value.

    TryRemoveAndDispose<TKey, TValue>(ConcurrentDictionary<TKey, TValue>, TKey)

    Try to remove key from concurrent dictionary and dispose the value.

    Declaration
    public static void TryRemoveAndDispose<TKey, TValue>(this ConcurrentDictionary<TKey, TValue> dictionary, TKey key)
    
        where TValue : IDisposable
    Parameters
    Type Name Description
    ConcurrentDictionary<TKey, TValue> dictionary

    Dictionary to clean up

    TKey key

    Key to lookup

    Type Parameters
    Name Description
    TKey

    Key type

    TValue

    Value type

    Back to top Copyright (c) Microsoft Corporation. All rights reserved.