Volume Control
Application-specific hotkeys for Windows
VolumeControl.TypeExtensions.EnumExtensions Class Reference

Extensions for any Enum type. More...

Collaboration diagram for VolumeControl.TypeExtensions.EnumExtensions:

Static Public Member Functions

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...
 

Detailed Description

Extensions for any Enum type.

Member Function Documentation

◆ 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
TThe enum type.
Parameters
eThe enum instance.
otherAny enumerable of type T .
Returns
True when e is equal to at least one value from other
Type Constraints
T :struct 
T :Enum 

◆ EqualsAny< T >() [2/2]

static bool VolumeControl.TypeExtensions.EnumExtensions.EqualsAny< T > ( this T  e,
params T[]  other 
)
static
Parameters
eThe enum instance.
otherAny 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
TThe 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 .
Type Constraints
T :struct 
T :Enum 

◆ 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
TThe 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.
Type Constraints
T :struct 
T :Enum 

◆ 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
TThe enum type.
Parameters
e(implicit) The enum value to check.
flagsThe flags to check.
Returns
true when the enum value has all of the flags set; otherwise, false.
Type Constraints
T :struct 
T :Enum 

◆ 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
TThe enum type.
Parameters
eThe enum instance.
otherAny enumerable of type T .
Returns
True when e is equal to at least one value from other
Type Constraints
T :struct 
T :Enum 

◆ HasAnyFlag< T >() [2/2]

static bool VolumeControl.TypeExtensions.EnumExtensions.HasAnyFlag< T > ( this T  e,
params T[]  other 
)
static
Parameters
eThe enum instance.
otherAny 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
TThe 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.
Type Constraints
T :struct 
T :Enum 

◆ SetFlagState< T >()

static T VolumeControl.TypeExtensions.EnumExtensions.SetFlagState< T > ( this T  e,
flag,
bool  state 
)
static

Returns the enum value with the specified flag changed.

Template Parameters
TThe type of enum being operated on.
Parameters
e(implicit) Enum value to operate on.
flagThe enum value of the flag to set or unset.
stateThe specified flag is set when true and unset when false.
Returns
The enum value with the specified flag set to the specified state .
Type Constraints
T :struct 
T :Enum 

◆ 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
TThe type of enum being operated on.
Parameters
e(implicit) Enum value to operate on.
flagStatesAny 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.
Type Constraints
T :struct 
T :Enum 

◆ Xor< T >()

static T VolumeControl.TypeExtensions.EnumExtensions.Xor< T > ( this T  e,
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
TThe type of enum being operated on.
Parameters
e(implicit) Enum value to operate on.
valueEnum value to operate on.
Returns
The result of the bitwise XOR operation.
Type Constraints
T :struct 
T :Enum 

The documentation for this class was generated from the following file: