Skip to content

EnumExtensions

Namespace: SideXP.Core

public static class EnumExtensions

Extension functions for enum values.

Methods

IsValid<TEnum>(TEnum)

public static bool IsValid<TEnum>(TEnum enumValue)

Checks if the given enumeration value matches an item.

Type parameters

  • TEnum: The enumeration type.

Parameters

  • enumValue: The enumeration value to check.

Returns

Returns true if the given enumeration value matches an item.

Invert<TEnum>(TEnum)

public static void Invert<TEnum>(ref TEnum enumValue)

Invert the given enumeration value: enabled flags become disabled flags, and vice-versa.

Type parameters

  • TEnum: The enumeration type.

Parameters

  • enumValue: The enumeration value to invert.

AddFlag<TEnum>(TEnum, TEnum)

public static void AddFlag<TEnum>(ref TEnum enumValue, TEnum flag)

Adds the given flag to the enum value.

Type parameters

  • TEnum: The enumeration type.

Parameters

  • enumValue: The enumeration value to which you want to add the flag.
  • flag: The flag to add.

RemoveFlag<TEnum>(TEnum, TEnum)

public static void RemoveFlag<TEnum>(ref TEnum enumValue, TEnum flag)

Removes the given flag from the enum value.

Type parameters

  • TEnum: The enumeration type.

Parameters

  • enumValue: The enumeration value from which you want to remove the flag.
  • flag: The flag to remove.