--- /dev/null
+/* EnumHelper.cs $\r
+ This file is part of the HandBrake source code.\r
+ Homepage: <http://handbrake.fr>.\r
+ It may be used under the terms of the GNU General Public License. */\r
+\r
+namespace HandBrake.ApplicationServices.Functions\r
+{\r
+ using System.ComponentModel;\r
+ using System.Reflection;\r
+ using System;\r
+\r
+ /// <summary>\r
+ /// Enum Helpers\r
+ /// </summary>\r
+ public class EnumHelper\r
+ {\r
+ /// <summary>\r
+ /// Get the description of an Enum\r
+ /// </summary>\r
+ /// <param name="value">\r
+ /// The value.\r
+ /// </param>\r
+ /// <returns>\r
+ /// The Description string\r
+ /// </returns>\r
+ public static string GetDescription(Enum value)\r
+ {\r
+ FieldInfo fieldInfo = value.GetType().GetField(value.ToString());\r
+ DescriptionAttribute[] attributes =\r
+ (DescriptionAttribute[])fieldInfo.GetCustomAttributes(\r
+ typeof(DescriptionAttribute), false);\r
+ return (attributes.Length > 0) ? attributes[0].Description : value.ToString();\r
+ }\r
+ }\r
+}\r