From 216796c29e353420eb42a633ce91916331f17909 Mon Sep 17 00:00:00 2001 From: adelikat Date: Thu, 3 Jul 2014 17:41:55 +0000 Subject: [PATCH] Remove enum helper and move the remaining method to ReflectionExtensions since that is more accurate to what it is doing --- .../Extensions/ControlExtensions.cs | 2 +- BizHawk.Common/BizHawk.Common.csproj | 1 - BizHawk.Common/Extensions/ReflectionExtensions.cs | 14 ++++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs b/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs index 4bcb1b8337..132b558508 100644 --- a/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs +++ b/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs @@ -21,7 +21,7 @@ namespace BizHawk.Client.EmuHawk.ControlExtensions box.Items.Clear(); box.Items.AddRange( - EnumHelper.GetDescriptions() + typeof(T).GetEnumDescriptions() .ToArray()); box.SelectedItem = enumVal.GetDescription(); } diff --git a/BizHawk.Common/BizHawk.Common.csproj b/BizHawk.Common/BizHawk.Common.csproj index c7207ab1c6..3fd9768eb4 100644 --- a/BizHawk.Common/BizHawk.Common.csproj +++ b/BizHawk.Common/BizHawk.Common.csproj @@ -52,7 +52,6 @@ - diff --git a/BizHawk.Common/Extensions/ReflectionExtensions.cs b/BizHawk.Common/Extensions/ReflectionExtensions.cs index d455f36c03..fe79331e02 100644 --- a/BizHawk.Common/Extensions/ReflectionExtensions.cs +++ b/BizHawk.Common/Extensions/ReflectionExtensions.cs @@ -138,5 +138,19 @@ namespace BizHawk.Common.ReflectionExtensions return null; } + + /// + /// Takes an enum Type and generates a list of strings from the description attributes + /// + /// + public static IEnumerable GetEnumDescriptions(this Type type) + { + var vals = Enum.GetValues(type); + + foreach (var v in vals) + { + yield return v.GetDescription(); + } + } } }