OSDN Git Service

import original 0.9.5 release
[handbrake-jp/handbrake-jp.git] / win / C# / HandBrake.ApplicationServices / Functions / EnumHelper.cs
diff --git a/win/C#/HandBrake.ApplicationServices/Functions/EnumHelper.cs b/win/C#/HandBrake.ApplicationServices/Functions/EnumHelper.cs
new file mode 100644 (file)
index 0000000..6cf7342
--- /dev/null
@@ -0,0 +1,35 @@
+/*  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