mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-12 12:07:05 +00:00
feat: Adding GetFlagsExceptNone parameterless enum util method
This commit is contained in:
parent
62abd624f8
commit
35593bfa47
1 changed files with 14 additions and 0 deletions
|
|
@ -289,6 +289,20 @@ namespace ICD.Common.Utils
|
||||||
return s_EnumFlagsCache[type][value].Cast<T>();
|
return s_EnumFlagsCache[type][value].Cast<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets all of the set flags on the given enum type except 0.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IEnumerable<T> GetFlagsExceptNone<T>()
|
||||||
|
{
|
||||||
|
if (!IsEnumType<T>())
|
||||||
|
throw new ArgumentException(string.Format("{0} is not an enum", typeof(T).Name));
|
||||||
|
|
||||||
|
T allValue = GetFlagsAllValue<T>();
|
||||||
|
return GetFlagsExceptNone(allValue);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets all of the set flags on the given enum except 0.
|
/// Gets all of the set flags on the given enum except 0.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue