Innovt Platform
Search Results for

    Show / Hide Table of Contents

    Class Extensions

    A collection of extension methods for common operations on collections and objects.

    Inheritance
    object
    Extensions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Innovt.Core.Collections
    Assembly: Innovt.Core.dll
    Syntax
    public static class Extensions
    Remarks

    This static class provides extension methods to simplify common operations on collections, such as checking for null or empty, adding items, and merging dictionaries.

    Methods

    | Edit this page View Source

    AddFluent<T>(IList<T>, T)

    Initialize the collection if is null, so you don't have to check it

    Declaration
    public static IList<T> AddFluent<T>(this IList<T> list, T value) where T : class
    Parameters
    Type Name Description
    IList<T> list
    T value
    Returns
    Type Description
    IList<T>
    Type Parameters
    Name Description
    T
    | Edit this page View Source

    AddFluent<TKey, TValue>(Dictionary<TKey, TValue>, TKey, TValue)

    Adds a key-value pair to the dictionary and initializes it if it is null.

    Declaration
    public static Dictionary<TKey, TValue> AddFluent<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key, TValue value)
    Parameters
    Type Name Description
    Dictionary<TKey, TValue> dictionary

    The Dictionary<TKey, TValue> to add to.

    TKey key

    The key to add to the dictionary.

    TValue value

    The value to add to the dictionary.

    Returns
    Type Description
    Dictionary<TKey, TValue>
    Type Parameters
    Name Description
    TKey

    The type of keys in the dictionary.

    TValue

    The type of values in the dictionary.

    | Edit this page View Source

    HasItems<T>(ICollection<T>)

    Returns if the collection has more items

    Declaration
    public static bool HasItems<T>(this ICollection<T> collection)
    Parameters
    Type Name Description
    ICollection<T> collection
    Returns
    Type Description
    bool

    true if the collection has more items; otherwise, false.

    Type Parameters
    Name Description
    T
    | Edit this page View Source

    IsNotNullOrEmpty<T>(ICollection<T>)

    Checks if an ICollection<T> is not null and not empty.

    Declaration
    public static bool IsNotNullOrEmpty<T>(this ICollection<T> collection)
    Parameters
    Type Name Description
    ICollection<T> collection

    The ICollection<T> to check.

    Returns
    Type Description
    bool

    true if the collection is not null and not empty; otherwise, false.

    Type Parameters
    Name Description
    T

    The type of elements in the collection.

    | Edit this page View Source

    IsNotNullOrEmpty<T>(IEnumerable<T>)

    Checks if an IEnumerable<T> is not null and not empty.

    Declaration
    public static bool IsNotNullOrEmpty<T>(this IEnumerable<T> enumerable)
    Parameters
    Type Name Description
    IEnumerable<T> enumerable

    The IEnumerable<T> to check.

    Returns
    Type Description
    bool

    true if the enumerable is not null and not empty; otherwise, false.

    Type Parameters
    Name Description
    T

    The type of elements in the enumerable.

    | Edit this page View Source

    IsNullOrEmpty<T>(ICollection<T>)

    Checks if an ICollection<T> is null or empty.

    Declaration
    public static bool IsNullOrEmpty<T>(this ICollection<T> collection)
    Parameters
    Type Name Description
    ICollection<T> collection

    The ICollection<T> to check.

    Returns
    Type Description
    bool

    true if the collection is null or empty; otherwise, false.

    Type Parameters
    Name Description
    T

    The type of elements in the collection.

    | Edit this page View Source

    IsNullOrEmpty<T>(IEnumerable<T>)

    Checks if an IEnumerable<T> is null or empty.

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

    The IEnumerable<T> to check.

    Returns
    Type Description
    bool

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

    Type Parameters
    Name Description
    T

    The type of elements in the enumerable.

    | Edit this page View Source

    IsNullOrEmpty<T>(IList<T>)

    Checks if an IList<T> is null or empty.

    Declaration
    public static bool IsNullOrEmpty<T>(this IList<T> list)
    Parameters
    Type Name Description
    IList<T> list

    The IList<T> to check.

    Returns
    Type Description
    bool

    true if the list is null or empty; otherwise, false.

    Type Parameters
    Name Description
    T

    The type of elements in the list.

    | Edit this page View Source

    MapToPagedCollection<T, T2>(IPagedCollection<T>)

    Using a simple mapper to map an page collection of objects to another page collection of objects

    Declaration
    public static PagedCollection<T2> MapToPagedCollection<T, T2>(this IPagedCollection<T> pageCollection) where T : class where T2 : class
    Parameters
    Type Name Description
    IPagedCollection<T> pageCollection
    Returns
    Type Description
    PagedCollection<T2>
    Type Parameters
    Name Description
    T
    T2
    | Edit this page View Source

    Merge<TKey, TValue>(Dictionary<TKey, TValue>, Dictionary<TKey, TValue>)

    Merges two dictionaries, adding values from the second dictionary to the first.

    Declaration
    public static Dictionary<TKey, TValue> Merge<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, Dictionary<TKey, TValue> dictionarySecond)
    Parameters
    Type Name Description
    Dictionary<TKey, TValue> dictionary

    The target Dictionary<TKey, TValue> to merge into.

    Dictionary<TKey, TValue> dictionarySecond

    The source dictionary to merge from.

    Returns
    Type Description
    Dictionary<TKey, TValue>

    The updated dictionary after merging.

    Type Parameters
    Name Description
    TKey

    The type of keys in the dictionaries.

    TValue

    The type of values in the dictionaries.

    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX