具备界面基础功能
This commit is contained in:
21
SHH.CameraDashboard/Core/EnumHelper.cs
Normal file
21
SHH.CameraDashboard/Core/EnumHelper.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
|
||||
namespace SHH.CameraDashboard
|
||||
{
|
||||
public static class EnumHelper
|
||||
{
|
||||
public static string GetDescription(Enum value)
|
||||
{
|
||||
FieldInfo fi = value.GetType().GetField(value.ToString());
|
||||
|
||||
DescriptionAttribute[] attributes =
|
||||
(DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
||||
|
||||
if (attributes != null && attributes.Length > 0)
|
||||
return attributes[0].Description;
|
||||
else
|
||||
return value.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user