From 35593bfa4746a0034f3d94a98a299483a2d66ff4 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Thu, 24 May 2018 10:03:38 -0400 Subject: [PATCH] feat: Adding GetFlagsExceptNone parameterless enum util method --- ICD.Common.Utils/EnumUtils.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ICD.Common.Utils/EnumUtils.cs b/ICD.Common.Utils/EnumUtils.cs index af3f1e9..30a37e1 100644 --- a/ICD.Common.Utils/EnumUtils.cs +++ b/ICD.Common.Utils/EnumUtils.cs @@ -289,6 +289,20 @@ namespace ICD.Common.Utils return s_EnumFlagsCache[type][value].Cast(); } + /// + /// Gets all of the set flags on the given enum type except 0. + /// + /// + /// + public static IEnumerable GetFlagsExceptNone() + { + if (!IsEnumType()) + throw new ArgumentException(string.Format("{0} is not an enum", typeof(T).Name)); + + T allValue = GetFlagsAllValue(); + return GetFlagsExceptNone(allValue); + } + /// /// Gets all of the set flags on the given enum except 0. ///