Extensions for any Enum type.
More...
|
static bool | EqualsAny< T > (this T e, IEnumerable< T > other) |
| Returns true if e is equal to any enum value present in other . More...
|
|
static bool | EqualsAny< T > (this T e, params T[] other) |
|
static bool | HasAnyFlag< T > (this T e, IEnumerable< T > other) |
| Returns true if e contains any enum value present in other . More...
|
|
static bool | HasAnyFlag< T > (this T e, params T[] other) |
|
static bool | HasAllFlags< T > (this T e, IEnumerable< T > flags) |
| Checks if the enum value has all of the specified flags set. More...
|
|
static bool | HasAllFlags< T > (this T e, params T[] flags) |
|
static T | SetFlagState< T > (this T e, T flag, bool state) |
| Returns the enum value with the specified flag changed. More...
|
|
static T | SetFlagStates< T > (this T e, params(T flag, bool state)[] flagStates) |
| Returns the enum value with any number of flags changed. More...
|
|
static T | Xor< T > (this T e, T value) |
| Performs an XOR bitwise operation on the enum and the specified value . More...
|
|
static T | GetSingleValue< T > (this IEnumerable< T > enumerable) |
| Gets a single merged value containing all of the flags in the enumerable . More...
|
|
static bool | IsSingleValue< T > (this T e) |
| Checks if the enum value has 0 or 1 bits set in total. More...
|
|
static T[] | GetSingleValues< T > (this T e) |
| Gets the flags that are set in the enum value as individual values. More...
|
|
Extensions for any Enum type.
◆ EqualsAny< T >() [1/2]
static bool VolumeControl.TypeExtensions.EnumExtensions.EqualsAny< T > |
( |
this T |
e, |
|
|
IEnumerable< T > |
other |
|
) |
| |
|
static |
Returns true if e is equal to any enum
value present in other .
- Template Parameters
-
- Parameters
-
e | The enum instance. |
other | Any enumerable of type T . |
- Returns
- True when e is equal to at least one value from other
◆ EqualsAny< T >() [2/2]
static bool VolumeControl.TypeExtensions.EnumExtensions.EqualsAny< T > |
( |
this T |
e, |
|
|
params T[] |
other |
|
) |
| |
|
static |
- Parameters
-
e | The enum instance. |
other | Any number of other enums of type T . |
- Type Constraints
-
T | : | struct | |
T | : | Enum | |
T | : | e.EqualsAny | |
T | : | other.AsEnumerable() | |
◆ GetSingleValue< T >()
static T VolumeControl.TypeExtensions.EnumExtensions.GetSingleValue< T > |
( |
this IEnumerable< T > |
enumerable | ) |
|
|
static |
Gets a single merged value containing all of the flags in the enumerable .
- Template Parameters
-
T | The type of enum being operated on. |
- Parameters
-
enumerable | (implicit) Enumerable containing enum values of type T . |
- Returns
- A single enum value containing all of the values in the enumerable .
◆ GetSingleValues< T >()
static T [] VolumeControl.TypeExtensions.EnumExtensions.GetSingleValues< T > |
( |
this T |
e | ) |
|
|
static |
Gets the flags that are set in the enum value as individual values.
- Template Parameters
-
T | The type of enum being operated on. |
- Parameters
-
e | (implicit) Enum value to operate on. |
- Returns
- An array of the flags that were set in the enum value; when no flags were set, the array contains 1 zero value.
◆ HasAllFlags< T >()
static bool VolumeControl.TypeExtensions.EnumExtensions.HasAllFlags< T > |
( |
this T |
e, |
|
|
IEnumerable< T > |
flags |
|
) |
| |
|
static |
Checks if the enum value has all of the specified flags set.
- Template Parameters
-
- Parameters
-
e | (implicit) The enum value to check. |
flags | The flags to check. |
- Returns
true
when the enum value has all of the flags set; otherwise, false
.
◆ HasAnyFlag< T >() [1/2]
static bool VolumeControl.TypeExtensions.EnumExtensions.HasAnyFlag< T > |
( |
this T |
e, |
|
|
IEnumerable< T > |
other |
|
) |
| |
|
static |
Returns true if e contains any enum
value present in other .
- Template Parameters
-
- Parameters
-
e | The enum instance. |
other | Any enumerable of type T . |
- Returns
- True when e is equal to at least one value from other
◆ HasAnyFlag< T >() [2/2]
static bool VolumeControl.TypeExtensions.EnumExtensions.HasAnyFlag< T > |
( |
this T |
e, |
|
|
params T[] |
other |
|
) |
| |
|
static |
- Parameters
-
e | The enum instance. |
other | Any number of other enums of type T . |
- Type Constraints
-
T | : | struct | |
T | : | Enum | |
T | : | e.HasAnyFlag | |
T | : | other.AsEnumerable() | |
◆ IsSingleValue< T >()
static bool VolumeControl.TypeExtensions.EnumExtensions.IsSingleValue< T > |
( |
this T |
e | ) |
|
|
static |
Checks if the enum value has 0 or 1 bits set in total.
- Template Parameters
-
T | The type of enum being operated on. |
- Parameters
-
e | (implicit) Enum value to operate on. |
- Returns
true
when the enum value is a power of 2; false
.
◆ SetFlagState< T >()
static T VolumeControl.TypeExtensions.EnumExtensions.SetFlagState< T > |
( |
this T |
e, |
|
|
T |
flag, |
|
|
bool |
state |
|
) |
| |
|
static |
Returns the enum value with the specified flag changed.
- Template Parameters
-
T | The type of enum being operated on. |
- Parameters
-
e | (implicit) Enum value to operate on. |
flag | The enum value of the flag to set or unset. |
state | The specified flag is set when true and unset when false . |
- Returns
- The enum value with the specified flag set to the specified state .
◆ SetFlagStates< T >()
static T VolumeControl.TypeExtensions.EnumExtensions.SetFlagStates< T > |
( |
this T |
e, |
|
|
params(T flag, bool state)[] |
flagStates |
|
) |
| |
|
static |
Returns the enum value with any number of flags changed.
- Template Parameters
-
T | The type of enum being operated on. |
- Parameters
-
e | (implicit) Enum value to operate on. |
flagStates | Any number of flag-state pairs. When state is true , the associated flag is set; otherwise when state is false , the associated flag is unset. |
- Returns
- The enum value with the specified flagStates changed.
◆ Xor< T >()
static T VolumeControl.TypeExtensions.EnumExtensions.Xor< T > |
( |
this T |
e, |
|
|
T |
value |
|
) |
| |
|
static |
Performs an XOR bitwise operation on the enum and the specified value .
Intended for use when the actual enum type is not known, such as within a generic method.
- Template Parameters
-
T | The type of enum being operated on. |
- Parameters
-
e | (implicit) Enum value to operate on. |
value | Enum value to operate on. |
- Returns
- The result of the bitwise XOR operation.
The documentation for this class was generated from the following file:
- /home/runner/work/volume-control/volume-control/VolumeControl.TypeExtensions/EnumExtensions.cs