43 lines
896 B
C#
43 lines
896 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
|
|
namespace Common
|
|
{
|
|
public class EnumDescription
|
|
{
|
|
public static string GetDescription(Enum enumValue)
|
|
{
|
|
if (enumValue == null)
|
|
{
|
|
return String.Empty;
|
|
}
|
|
|
|
string strValue = enumValue.ToString();
|
|
|
|
Type enumType = enumValue.GetType();
|
|
|
|
FieldInfo fieldInfo = enumType.GetField(strValue);
|
|
|
|
Object[] attributes = fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
|
|
|
if (attributes != null && attributes.Length > 0)
|
|
{
|
|
return (attributes[0] as DescriptionAttribute).Description;
|
|
}
|
|
|
|
return strValue;
|
|
}
|
|
|
|
public static Dictionary<string, object> GetNameValueList(Type enumType)
|
|
{
|
|
Dictionary<string, object> nameValueList = new Dictionary<string, object>();
|
|
|
|
return nameValueList;
|
|
}
|
|
}
|
|
}
|