mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-01-11 19:44:55 +00:00
feat: SetFlags enum extension
This commit is contained in:
committed by
Chris Cameron
parent
841b692727
commit
f601f9cda7
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user