修改
This commit is contained in:
@@ -3,7 +3,9 @@ using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Domain.Share.Reading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -37,5 +39,19 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
||||
return ReadModuleEnum.ReadComplete;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取DisplayName
|
||||
/// </summary>
|
||||
/// <param name="enumName"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetDisplayName(this Enum enumName)
|
||||
{
|
||||
var type = enumName.GetType();//先获取这个枚举的类型
|
||||
var field = type.GetField(enumName.ToString());//通过这个类型获取到值
|
||||
var obj = (DisplayAttribute)field.GetCustomAttribute(typeof(DisplayAttribute));//得到特性
|
||||
return obj.Name ?? "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user