Skip to content

EnumExtensions Class ​

Definition ​

Extension methods for enum's

  • Namespace: JASE.Extensions
  • Assembly: JASE.Primitives.dll

Methods ​

NameDescription
bool CheckFlag(T input, T flag)Checks enumerator for the requested flag
T GetDefaultValue()Get the default value of an enum as a string
string GetFriendlyName(MemberInfo member)Retrieves a user-friendly name for the specified enum member.
List<string> GetListText(T input)Get a list of the enum members as strings
IReadOnlyList<EnumMemberInfo> GetMemberList()Returns a list containing EnumMemberInfo for each Enum member
List<T> GetSetFlags(T input)Returns a list of the flags set in a bitmasked enumerator
List<string> GetSetFlagsAsString(T input)Returns a list of the flags set in a bitmasked enumerator
bool HasAllFlag(bool allowMaxEqualAll = null)Determines whether the specified enum type includes a value that represents all defined flags.
bool HasAllFlag(out long allFlagValue, bool allowMaxEqualAll = null)Determines whether the specified enum type includes a value that represents all defined flags, and returns the value if found.
bool HasFlag(T input, T flag)Checks enumerator for the requested flag
bool IsValid(T value)Determines if a value is a valid member of the enum.
bool IsValidBitmask(bool allowMaxEqualAll = null, bool allowZero = null)Determines whether the specified enum type represents a valid bitmask structure, where each value (excluding any explicitly defined "All" value) is a power of two.
T RemoveFlag(T input, T flag)Removes the requested enumeration from the input value
T SetFlag(T input, T flag)Sets the requested enumeration flag
string Text(Enum enumeration)Returns Text/String representation of the enumerated value
string ToJsonObject()Converts an Enum to a JSON object representing its label and value pairs
string ToText(Enum enumeration)Returns Text/String representation of the enumerated value
T UnsetFlag(T input, T flag)Unsets the requested enumeration flag