summaryrefslogtreecommitdiffstats
path: root/win/C#/HandBrake.ApplicationServices/Functions/EnumHelper.cs
diff options
context:
space:
mode:
Diffstat (limited to 'win/C#/HandBrake.ApplicationServices/Functions/EnumHelper.cs')
-rw-r--r--win/C#/HandBrake.ApplicationServices/Functions/EnumHelper.cs35
1 files changed, 35 insertions, 0 deletions
diff --git a/win/C#/HandBrake.ApplicationServices/Functions/EnumHelper.cs b/win/C#/HandBrake.ApplicationServices/Functions/EnumHelper.cs
new file mode 100644
index 000000000..6cf7342a9
--- /dev/null
+++ b/win/C#/HandBrake.ApplicationServices/Functions/EnumHelper.cs
@@ -0,0 +1,35 @@
+/* EnumHelper.cs $
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr>.
+ It may be used under the terms of the GNU General Public License. */
+
+namespace HandBrake.ApplicationServices.Functions
+{
+ using System.ComponentModel;
+ using System.Reflection;
+ using System;
+
+ /// <summary>
+ /// Enum Helpers
+ /// </summary>
+ public class EnumHelper
+ {
+ /// <summary>
+ /// Get the description of an Enum
+ /// </summary>
+ /// <param name="value">
+ /// The value.
+ /// </param>
+ /// <returns>
+ /// The Description string
+ /// </returns>
+ 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();
+ }
+ }
+}