EnumFlagHelper Class
Namespace: PTS
Assembly: PTSframework.dll
Provides a set of static methods for enum
flags.
Syntax
public static class EnumFlagHelper
Inheritance
Methods
ClearFlags<TEnum>(TEnum, TEnum)
Removes specified flags from given value.
Declaration
public static TEnum ClearFlags<TEnum>(this TEnum value, TEnum flags)
where TEnum : Enum
Parameters
Type | Name | Description |
---|---|---|
TEnum | value | Value to remove the flags from. |
TEnum | flags | Flags to be removed. |
Returns
Type | Description |
---|---|
TEnum | A new set of flags without the specified flag options. |
Type Parameters
Name | Description |
---|---|
TEnum | Type of |
CombineFlags<TEnum>(IEnumerable<TEnum>)
Creates flag superset as single value from collection of value options.
Declaration
public static TEnum CombineFlags<TEnum>(this IEnumerable<TEnum> flags)
where TEnum : Enum
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TEnum> | flags | Discrete enum values to be combined into flag set. |
Returns
Type | Description |
---|---|
TEnum | A new set of flags with specified values. |
Type Parameters
Name | Description |
---|---|
TEnum | Type of |
Flags<TEnum>(TEnum)
Extracts flags from given value to enumerable object.
Declaration
public static IEnumerable<TEnum> Flags<TEnum>(this TEnum value)
where TEnum : Enum
Parameters
Type | Name | Description |
---|---|---|
TEnum | value | The value to extract the flags from. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TEnum> | Collection of flags assigned in the value. |
Type Parameters
Name | Description |
---|---|
TEnum | Type of |
IsFlagSet<TEnum>(TEnum, TEnum)
Checks whether specified flag is set in given value.
Declaration
public static bool IsFlagSet<TEnum>(this TEnum value, TEnum flag)
where TEnum : Enum
Parameters
Type | Name | Description |
---|---|---|
TEnum | value | Enum value to test. |
TEnum | flag | Flag value to look for. |
Returns
Type | Description |
---|---|
System.Boolean | If the value contains specified flag then |
Type Parameters
Name | Description |
---|---|
TEnum | Type of |
SetFlags<TEnum>(TEnum, TEnum)
Assigns flags to given value.
Declaration
public static TEnum SetFlags<TEnum>(this TEnum value, TEnum flags)
where TEnum : Enum
Parameters
Type | Name | Description |
---|---|---|
TEnum | value | Enum value to set the flags for. |
TEnum | flags | The flags to set. |
Returns
Type | Description |
---|---|
TEnum | A new set of flags with specified values. |
Type Parameters
Name | Description |
---|---|
TEnum | Type of |
SetFlags<TEnum>(TEnum, TEnum, Boolean)
Assigns flags to given value with specified state.
Declaration
public static TEnum SetFlags<TEnum>(this TEnum value, TEnum flags, bool flagState)
where TEnum : Enum
Parameters
Type | Name | Description |
---|---|---|
TEnum | value | Enum value to set the flags for. |
TEnum | flags | The flags to set. |
System.Boolean | flagState | Toggles whether set flags are included or excluded. |
Returns
Type | Description |
---|---|
TEnum | A new set of flags with specified values and state. |
Type Parameters
Name | Description |
---|---|
TEnum | Type of |