public EnumBitMask32(TEnum enumValue) { if (EnumConv.ToInt32(enumValue) != 0) { m_mask = EnumToBit(enumValue); } else { m_mask = 0; } }
public EnumBitMask(TEnum enumValue) { BitArray mask = null; if (EnumConv.ToInt32(enumValue) != 0) { mask = new BitArray(s_numBits); mask.Set(EnumConv.ToInt32(enumValue) - 1, true); } m_mask = mask; }
public EnumBitMask(IEnumerable <TEnum> enumValues) { BitArray mask = null; if (enumValues.Any()) { mask = new BitArray(s_numBits); foreach (TEnum e in enumValues) { mask.Set(EnumConv.ToInt32(e) - 1, true); } } m_mask = mask; }
uint EnumToBit(TEnum e) { return(1U << (EnumConv.ToInt32(e) - 1)); }
ulong EnumToBit(TEnum e) { return(1UL << (EnumConv.ToInt32(e) - 1)); }
/// <summary> /// Of /// </summary> /// <param name="member"></param> /// <param name="enumType"></param> /// <param name="defaultVal"></param> /// <returns></returns> public static object Of(object member, Type enumType, object defaultVal = default) { return(EnumConv.ToEnum(member, enumType, defaultVal)); }
/// <summary> /// Of /// </summary> /// <param name="member"></param> /// <param name="enumType"></param> /// <param name="ignoreCase"></param> /// <param name="defaultVal"></param> /// <returns></returns> public static object Of(string member, Type enumType, bool ignoreCase = false, object defaultVal = default) { return(EnumConv.ToEnum(member, enumType, ignoreCase, defaultVal)); }
/// <summary> /// Of /// </summary> /// <param name="member"></param> /// <param name="defaultVal"></param> /// <typeparam name="TEnum"></typeparam> /// <returns></returns> public static TEnum Of <TEnum>(object member, TEnum defaultVal = default) where TEnum : struct, Enum { return(EnumConv.ToEnum(member, defaultVal)); }
/// <summary> /// Of /// </summary> /// <param name="member"></param> /// <param name="ignoreCase"></param> /// <param name="defaultVal"></param> /// <typeparam name="TEnum"></typeparam> /// <returns></returns> public static TEnum Of <TEnum>(string member, bool ignoreCase = false, TEnum defaultVal = default) where TEnum : struct, Enum { return(EnumConv.ToEnum(member, ignoreCase, defaultVal)); }
public static int GetEnumMax <TEnum>() { return(EnumConv.ToInt32(GetEnumValues <TEnum>().Max())); }
public bool Get(TEnum enumValue) { return(m_mask != null && m_mask.Get(EnumConv.ToInt32(enumValue) - 1)); }