diff --git a/ICD.Common.Utils/EnumUtils.cs b/ICD.Common.Utils/EnumUtils.cs
index be5ff95..6725f52 100644
--- a/ICD.Common.Utils/EnumUtils.cs
+++ b/ICD.Common.Utils/EnumUtils.cs
@@ -219,6 +219,64 @@ namespace ICD.Common.Utils
#region Flags
+ ///
+ /// Excludes b from a.
+ ///
+ ///
+ ///
+ ///
+ public static T ExcludeFlags(T a, T b)
+ where T : struct, IConvertible
+ {
+ if (!IsEnumType())
+ throw new ArgumentException(string.Format("{0} is not an enum", typeof(T).Name));
+
+ int aInt = (int)(object)a;
+ int bInt = (int)(object)b;
+
+ return (T)(object)ExcludeFlags(aInt, bInt);
+ }
+
+ ///
+ /// Excludes b from a.
+ ///
+ ///
+ ///
+ ///
+ public static int ExcludeFlags(int a, int b)
+ {
+ return a & ~b;
+ }
+
+ ///
+ /// Includes a and b.
+ ///
+ ///
+ ///
+ ///
+ public static T IncludeFlags(T a, T b)
+ where T : struct, IConvertible
+ {
+ if (!IsEnumType())
+ throw new ArgumentException(string.Format("{0} is not an enum", typeof(T).Name));
+
+ int aInt = (int)(object)a;
+ int bInt = (int)(object)b;
+
+ return (T)(object)IncludeFlags(aInt, bInt);
+ }
+
+ ///
+ /// Includes a and b.
+ ///
+ ///
+ ///
+ ///
+ public static int IncludeFlags(int a, int b)
+ {
+ return a | b;
+ }
+
///
/// Gets the overlapping values of the given enum flags.
///
@@ -231,6 +289,9 @@ namespace ICD.Common.Utils
if (values == null)
throw new ArgumentNullException("values");
+ if (!IsEnumType())
+ throw new ArgumentException(string.Format("{0} is not an enum", typeof(T).Name));
+
if (values.Length == 0)
return default(T);
@@ -266,6 +327,9 @@ namespace ICD.Common.Utils
public static T GetFlagsIntersection(T a, T b)
where T : struct, IConvertible
{
+ if (!IsEnumType())
+ throw new ArgumentException(string.Format("{0} is not an enum", typeof(T).Name));
+
int aInt = (int)(object)a;
int bInt = (int)(object)b;