Class EnumExtensions
Provides generic methods for bitwise operations and validation on enumerations.
Inheritance
Namespace: Singulink.Enums
Assembly: Singulink.Enums.dll
Syntax
public static class EnumExtensions
Methods
| Name | Description |
|---|---|
| AreFlagsDefined<T>(T) | Determines whether the value's flags are all defined and they are a valid combination (i.e. the value can actually be represented by combining defined flags). |
| AsString<T>(T) | Gets a string representation of the specified enumeration value. |
| AsString<T>(T, SplitFlagsOptions) | Gets a string representation of the specified enumeration value using the specified options to customize how flags are split. |
| ClearFlags<T>(T, IEnumerable<T>) | Clears the specified flags on the value. |
| ClearFlags<T>(T, params ReadOnlySpan<T>) | Clears the specified flags on the value. |
| ClearFlags<T>(T, T) | Clears the specified flags on the value. |
| ClearFlags<T>(T, T, T) | Clears the specified flags on the value. |
| ClearFlags<T>(T, T, T, T) | Clears the specified flags on the value. |
| ClearFlags<T>(T, params T[]) | Clears the specified flags on the value. |
| GetName<T>(T) | Gets the first enumeration name with the given value. |
| HasAllFlags<T>(T, IEnumerable<T>) | Determines whether the value has all the given flags. |
| HasAllFlags<T>(T, params ReadOnlySpan<T>) | Determines whether the value has all the given flags. |
| HasAllFlags<T>(T, T) | Determines whether the value has all the given flags. |
| HasAllFlags<T>(T, T, T) | Determines whether the value has all the given flags. |
| HasAllFlags<T>(T, T, T, T) | Determines whether the value has all the given flags. |
| HasAllFlags<T>(T, params T[]) | Determines whether the value has all the given flags. |
| HasAnyFlag<T>(T, IEnumerable<T>) | Determines whether the value has any of the given flags. |
| HasAnyFlag<T>(T, params ReadOnlySpan<T>) | Determines whether the value has any of the given flags. |
| HasAnyFlag<T>(T, T) | Determines whether the value has any of the given flags. |
| HasAnyFlag<T>(T, T, T) | Determines whether the value has any of the given flags. |
| HasAnyFlag<T>(T, T, T, T) | Determines whether the value has any of the given flags. |
| HasAnyFlag<T>(T, params T[]) | Determines whether the value has any of the given flags. |
| HasSingleBitSet<T>(T) | Determines whether the value has a single bit set (i.e., only one flag is set). |
| IsDefined<T>(T) | Determines whether the value is defined. |
| IsValid<T>(T) | Uses the custom IEnumValidatorAttribute<T> if available to check if the value is valid, otherwise checks whether the value is defined for regular enumerations, or checks whether the value's flags are all defined for flags enumerations. |
| SetFlags<T>(T, IEnumerable<T>) | Sets the specified flags on the value. |
| SetFlags<T>(T, params ReadOnlySpan<T>) | Sets the specified flags on the value. |
| SetFlags<T>(T, T) | Sets the specified flags on the value. |
| SetFlags<T>(T, T, T) | Sets the specified flags on the value. |
| SetFlags<T>(T, T, T, T) | Sets the specified flags on the value. |
| SetFlags<T>(T, params T[]) | Sets the specified flags on the value. |
| SplitFlags<T>(T, SplitFlagsOptions) | Splits the value into the defined flags that make up the value, plus any remainder (if ExcludeRemainder is not set). Defined flags are returned in descending order based on the highest bits set first. |
| ThrowIfFlagsAreNotDefined<TEnum>(TEnum, string) | Throws an ArgumentOutOfRangeException if the value's flags are not all defined or they are not a valid combination (i.e. the value cannot actually be represented by combining defined flags). |
| ThrowIfNotDefined<TEnum>(TEnum, string) | Throws an ArgumentOutOfRangeException if the value is not defined. |
| ThrowIfNotValid<TEnum>(TEnum, string) | Throws an ArgumentOutOfRangeException if the value is not valid. |
| TryGetName<T>(T, out string?) | Gets the first enumeration name with the given value. |