Class FlagsEnum
- Namespace
- Arc4u
- Assembly
- Arc4u.dll
Provides extension methods for flags enumerations.
public static class FlagsEnum
- Inheritance
-
FlagsEnum
- Inherited Members
Methods
ContinuousFlagValues<TEnum>(TEnum)
Indicates if the flag values of the specified value are continuous or not.
public static bool ContinuousFlagValues<TEnum>(TEnum value) where TEnum : struct
Parameters
valueTEnumA combined value of
TEnum.
Returns
- bool
true if the flag values of the specified
valueare continuous; otherwise, false.
Type Parameters
TEnumAn enumeration type.
Exceptions
- ArgumentException
TEnumis not an enumeration type.
FlagValues<TEnum>()
Gets the flag values defined in TEnum.
public static IEnumerable<TEnum> FlagValues<TEnum>() where TEnum : struct
Returns
- IEnumerable<TEnum>
The defined flag values.
Type Parameters
TEnumAn enumeration type.
Exceptions
- ArgumentException
TEnumis not an enumeration type.
FlagValues<TEnum>(TEnum)
Gets the flag values of the specified value.
public static IEnumerable<TEnum> FlagValues<TEnum>(TEnum value) where TEnum : struct
Parameters
valueTEnumA combined value of
TEnum.
Returns
- IEnumerable<TEnum>
The flag values of the specified
value.
Type Parameters
TEnumAn enumeration type.
Exceptions
- ArgumentException
TEnumis not an enumeration type.
FlaggedValues<TEnum>()
Gets the flagged values defined in TEnum.
public static IEnumerable<TEnum> FlaggedValues<TEnum>() where TEnum : struct
Returns
- IEnumerable<TEnum>
The defined flagged values.
Type Parameters
TEnumAn enumeration type.
Exceptions
- ArgumentException
TEnumis not an enumeration type.
PowerOfTwoExponent(object)
Gets the power of two exponent from the specified value.
public static int PowerOfTwoExponent(object value)
Parameters
valueobjectA value.
Returns
- int
The power of two exponent from the specified
value.
Exceptions
- ArgumentException
valueis not a power of two exponent.
PowerOfTwo<TEnum>(object)
Gets a value of TEnum from two raised to the specified power.
public static TEnum PowerOfTwo<TEnum>(object power) where TEnum : struct
Parameters
powerobjectThe raising power of two.
Returns
- TEnum
The matching value of
TEnum.
Type Parameters
TEnumAn enumeration type.
Exceptions
- ArgumentException
TEnumis not an enumeration type -or- no match found in the defined values ofTEnum.
TryPowerOfTwoExponent(object?, out int, float)
Tries to get the power of two exponent from the specified value.
public static bool TryPowerOfTwoExponent(object? value, out int result, float epsilon = 1E-07)
Parameters
valueobjectA value.
resultintWhen this methods returns, contains the power of two exponent from the specified
value. This parameter is passed uninitialized.epsilonfloatThe tolerance used when checking that the exponent is an integer.
Returns
- bool
true if the
valueparameter is a power of two exponent; otherwise, false.
TryPowerOfTwo<TEnum>(object, out TEnum, float)
Tries to get a value of TEnum from two raised to the specified power.
public static bool TryPowerOfTwo<TEnum>(object power, out TEnum result, float epsilon = 1E-07) where TEnum : struct
Parameters
powerobjectThe raising power of two.
resultTEnumWhen this methods returns, contains the matching value of
TEnum. This parameter is passed uninitialized.epsilonfloatThe tolerance used when checking that the computed value is an integer.
Returns
- bool
true if a matching value of
TEnumis found; otherwise, false.
Type Parameters
TEnumAn enumeration type.