110,534
社区成员
发帖
与我相关
我的任务
分享
public static System.Collections.IList GetEumnValues(Type type)
{
return GetEumnValues(type, true);
}
public static System.Collections.IList GetEumnValues(Type type, bool isOnly)
{
return GetEumnValues<DescriptionAttribute>(type, isOnly);
}
public static System.Collections.IList GetEumnValues<T>(Type type)
where T : DescriptionAttribute
{
return GetEumnValues<T>(type, true);
}
public static System.Collections.IList GetEumnValues<T>(Type type, bool isOnly)
where T : DescriptionAttribute
{
if (type == null)
return null;
if (!type.IsEnum)
return null;
ArrayList list = new ArrayList();
Array array = Enum.GetValues(type);
foreach (Enum value in array)
list.Add(new KeyValuePair<Enum, string>(value, GetEumnValue<T>(value, isOnly)));
return list;
}
public static Enum AnalyEnum(string str, Type t)
{
ArrayList al = (ArrayList)WiBase.DEnum.GetEumnValues(t);
foreach (var i in al)
{
KeyValuePair<Enum, string> s = (KeyValuePair<Enum, string>)i;
if (s.Value.ToLower().Trim() == str.ToLower().Trim())
return s.Key;
}
return null;
}