Exemplo n.º 1
0
        /// <summary>
        /// 添加描述项
        /// </summary>
        private static void AddItem(Type type, ICollection <Item> result, FieldInfo field)
        {
            if (!field.FieldType.IsEnum)
            {
                return;
            }
            var value       = GetValue(type, field.Name);
            var description = Reflection.GetDescription(field);

            result.Add(new Item(description, value, value));
        }
Exemplo n.º 2
0
 /// <summary>
 /// 获取描述,使用System.ComponentModel.Description特性设置描述
 /// </summary>
 /// <typeparam name="TEnum">枚举类型</typeparam>
 /// <param name="member">成员名、值、实例均可</param>
 public static string GetDescription <TEnum>(object member)
 {
     return(Reflection.GetDescription <TEnum>(GetName <TEnum>(member)));
 }
Exemplo n.º 3
0
 /// <summary>
 /// 获取描述,使用System.ComponentModel.Description特性设置描述
 /// </summary>
 /// <param name="type">枚举类型</param>
 /// <param name="member">成员名、值、实例均可</param>
 public static string GetDescription(Type type, object member)
 {
     return(Reflection.GetDescription(type, GetName(type, member)));
 }