feat: SetFlags enum extension

This commit is contained in:
Drew Tingen
2021-06-17 09:47:43 -04:00
committed by Chris Cameron
parent 841b692727
commit f601f9cda7

View File

@@ -61,6 +61,22 @@ namespace ICD.Common.Utils.Extensions
return EnumUtils.IncludeFlags(extends, other);
}
/// <summary>
/// Returns the enum, with the other flags set or unset
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="extends"></param>
/// <param name="other"></param>
/// <param name="set"></param>
/// <returns></returns>
public static T SetFlags<T>(this T extends, T other, bool set)
where T : struct, IConvertible
{
return set ?
EnumUtils.IncludeFlags(extends, other) :
EnumUtils.ExcludeFlags(extends, other);
}
/// <summary>
/// Returns the enum value as a ushort.
/// </summary>