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