Unosquare
    Show / Hide Table of Contents

    Class EnumHelper

    Provide Enumerations helpers with internal cache.

    Inheritance
    Object
    SingletonBase<CollectionCacheRepository<Tuple<String, Object>>>
    EnumHelper
    Inherited Members
    SingletonBase<CollectionCacheRepository<Tuple<String, Object>>>.LazyInstance
    SingletonBase<CollectionCacheRepository<Tuple<String, Object>>>.Instance
    SingletonBase<CollectionCacheRepository<Tuple<String, Object>>>.Dispose()
    SingletonBase<CollectionCacheRepository<Tuple<String, Object>>>.Dispose(Boolean)
    Namespace: Swan
    Syntax
    public class EnumHelper : SingletonBase<CollectionCacheRepository<Tuple<string, object>>>

    Methods

    GetFlagNames<TEnum>(Byte, Boolean, Boolean)

    Gets the flag names.

    Declaration
    public static IEnumerable<string> GetFlagNames<TEnum>(byte value, bool ignoreZero = false, bool humanize = true)
        where TEnum : struct, IConvertible
    Parameters
    Type Name Description
    Byte value

    The value.

    Boolean ignoreZero

    if set to true [ignore zero].

    Boolean humanize

    if set to true [humanize].

    Returns
    Type Description
    IEnumerable<String>

    A list of flag names.

    Type Parameters
    Name Description
    TEnum

    The type of the enum.

    GetFlagNames<TEnum>(Int32, Boolean, Boolean)

    Gets the flag names.

    Declaration
    public static IEnumerable<string> GetFlagNames<TEnum>(int value, bool ignoreZero = false, bool humanize = true)
        where TEnum : struct, IConvertible
    Parameters
    Type Name Description
    Int32 value

    the value.

    Boolean ignoreZero

    if set to true [ignore zero].

    Boolean humanize

    if set to true [humanize].

    Returns
    Type Description
    IEnumerable<String>

    A list of flag names.

    Type Parameters
    Name Description
    TEnum

    The type of the enum.

    GetFlagNames<TEnum>(Int64, Boolean, Boolean)

    Gets the flag names.

    Declaration
    public static IEnumerable<string> GetFlagNames<TEnum>(long value, bool ignoreZero = false, bool humanize = true)
        where TEnum : struct, IConvertible
    Parameters
    Type Name Description
    Int64 value

    The value.

    Boolean ignoreZero

    if set to true [ignore zero].

    Boolean humanize

    if set to true [humanize].

    Returns
    Type Description
    IEnumerable<String>

    A list of flag names.

    Type Parameters
    Name Description
    TEnum

    The type of the enum.

    GetFlagValues<TEnum>(Byte, Boolean)

    Gets the flag values.

    Declaration
    public static IEnumerable<byte> GetFlagValues<TEnum>(byte value, bool ignoreZero = false)
        where TEnum : struct, IConvertible
    Parameters
    Type Name Description
    Byte value

    The value.

    Boolean ignoreZero

    if set to true [ignore zero].

    Returns
    Type Description
    IEnumerable<Byte>

    A list of values in the flag.

    Type Parameters
    Name Description
    TEnum

    The type of the enum.

    GetFlagValues<TEnum>(Int32, Boolean)

    Gets the flag values.

    Declaration
    public static IEnumerable<int> GetFlagValues<TEnum>(int value, bool ignoreZero = false)
        where TEnum : struct, IConvertible
    Parameters
    Type Name Description
    Int32 value

    The value.

    Boolean ignoreZero

    if set to true [ignore zero].

    Returns
    Type Description
    IEnumerable<Int32>

    A list of values in the flag.

    Type Parameters
    Name Description
    TEnum

    The type of the enum.

    GetFlagValues<TEnum>(Int64, Boolean)

    Gets the flag values.

    Declaration
    public static IEnumerable<long> GetFlagValues<TEnum>(long value, bool ignoreZero = false)
        where TEnum : struct, IConvertible
    Parameters
    Type Name Description
    Int64 value

    The value.

    Boolean ignoreZero

    if set to true [ignore zero].

    Returns
    Type Description
    IEnumerable<Int64>

    A list of values in the flag.

    Type Parameters
    Name Description
    TEnum

    The type of the enum.

    GetItemsWithIndex<T>(Boolean)

    Gets the cached items with the enum item index.

    Declaration
    public static IEnumerable<Tuple<int, string>> GetItemsWithIndex<T>(bool humanize = true)
        where T : struct, IConvertible
    Parameters
    Type Name Description
    Boolean humanize

    if set to true [humanize].

    Returns
    Type Description
    IEnumerable<Tuple<Int32, String>>

    A collection of Type/Tuple pairs that represents items with the enum item value.

    Type Parameters
    Name Description
    T

    The type of enumeration.

    GetItemsWithValue<T>(Boolean)

    Gets the cached items with the enum item value.

    Declaration
    public static IEnumerable<Tuple<int, string>> GetItemsWithValue<T>(bool humanize = true)
        where T : struct, IConvertible
    Parameters
    Type Name Description
    Boolean humanize

    if set to true [humanize].

    Returns
    Type Description
    IEnumerable<Tuple<Int32, String>>

    A collection of Type/Tuple pairs that represents items with the enum item value.

    Type Parameters
    Name Description
    T

    The type of enumeration.

    Retrieve<T>()

    Gets all the names and enumerators from a specific Enum type.

    Declaration
    public static IEnumerable<Tuple<string, object>> Retrieve<T>()
        where T : struct, IConvertible
    Returns
    Type Description
    IEnumerable<Tuple<String, Object>>

    A tuple of enumerator names and their value stored for the specified type.

    Type Parameters
    Name Description
    T

    The type of the attribute to be retrieved.

    Comments

    Back to top Copyright © 2017-2019 Unosquare