From f601f9cda74a41beb80c6e43a1b560a6a87ad483 Mon Sep 17 00:00:00 2001 From: Drew Tingen Date: Thu, 17 Jun 2021 09:47:43 -0400 Subject: [PATCH] feat: SetFlags enum extension --- ICD.Common.Utils/Extensions/EnumExtensions.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ICD.Common.Utils/Extensions/EnumExtensions.cs b/ICD.Common.Utils/Extensions/EnumExtensions.cs index fbbb9d0..f4144c7 100644 --- a/ICD.Common.Utils/Extensions/EnumExtensions.cs +++ b/ICD.Common.Utils/Extensions/EnumExtensions.cs @@ -61,6 +61,22 @@ namespace ICD.Common.Utils.Extensions return EnumUtils.IncludeFlags(extends, other); } + /// + /// Returns the enum, with the other flags set or unset + /// + /// + /// + /// + /// + /// + public static T SetFlags(this T extends, T other, bool set) + where T : struct, IConvertible + { + return set ? + EnumUtils.IncludeFlags(extends, other) : + EnumUtils.ExcludeFlags(extends, other); + } + /// /// Returns the enum value as a ushort. ///