using System; using System.Collections.Generic; using System.Linq; using Humanizer; namespace Artemis.Core { /// /// Provides utilities for display enums in a human readable form /// public static class EnumUtilities { /// /// Creates a list containing a tuple for each value in the enum type /// /// The enum type to create value descriptions for /// A list containing a value-description tuple for each value in the enum type public static List<(T, string)> GetAllValuesAndDescriptions() where T : struct, Enum { return Enum.GetValues().Select(e => (e, e.Humanize())).ToList(); } /// /// Creates a list containing a tuple for each value in the enum type /// /// The enum type to create value descriptions for /// A list containing a value-description tuple for each value in the enum type public static List<(Enum, string)> GetAllValuesAndDescriptions(Type t) { if (!t.IsEnum) throw new ArgumentException($"{t} must be an enum type"); return Enum.GetValues(t).Cast().Select(e => (e, e.Humanize())).ToList(); } } }