summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs14
1 files changed, 14 insertions, 0 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs b/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs
index 657434f31..53d7f6069 100644
--- a/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs
+++ b/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs
@@ -7,6 +7,7 @@ namespace HandBrake.ApplicationServices.Functions
{
using System;
using System.ComponentModel;
+ using System.ComponentModel.DataAnnotations;
using System.Reflection;
/// <summary>
@@ -36,6 +37,19 @@ namespace HandBrake.ApplicationServices.Functions
}
/// <summary>
+ /// Get the Display Value of the Enum Model
+ /// </summary>
+ /// <param name="value">An Enum with Display Attributes</param>
+ /// <returns>A string name</returns>
+ public static string GetDisplayValue(T value)
+ {
+ FieldInfo fieldInfo = value.GetType().GetField(value.ToString());
+ DisplayAttribute[] attributes = (DisplayAttribute[])fieldInfo.GetCustomAttributes(typeof(DisplayAttribute), false);
+
+ return (attributes.Length > 0) ? attributes[0].Name : value.ToString();
+ }
+
+ /// <summary>
/// Get the Enumeration for a given Enum Description
/// </summary>
/// <param name="description">The String description</param>