using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.NET.Application
{
public static class EnumHelper
{
///
/// 枚举值的 ErrorCodeItemMetadataAttribute 方法
///
///
///
public static ErrorCodeItemMetadataAttribute GetErrorCodeItemMetadata(this ErrorCodeEnum errorCode)
{
var fieldInfo = errorCode.GetType().GetField(errorCode.ToString());
var attributes = fieldInfo.GetCustomAttributes(typeof(ErrorCodeItemMetadataAttribute), false);
return attributes.Length > 0 ? (ErrorCodeItemMetadataAttribute)attributes[0] : null;
}
}
}