You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
867 B
37 lines
867 B
using System.Reflection;
|
|
|
|
namespace Service.Execute.Tech;
|
|
|
|
public class RemarkAttribute : Attribute
|
|
{
|
|
private string _Remark;
|
|
|
|
public RemarkAttribute(string remark)
|
|
{
|
|
this._Remark = remark;
|
|
}
|
|
|
|
public string GetRemark()
|
|
{
|
|
return this._Remark;
|
|
}
|
|
}
|
|
|
|
public static class RemarkExtend
|
|
{
|
|
public static string GetRemark(this global::System.Enum value)
|
|
{
|
|
Type type = value.GetType();
|
|
FieldInfo? fieldInfo = type.GetField(value.ToString());
|
|
if (fieldInfo != null && fieldInfo.IsDefined(typeof(RemarkAttribute), true))
|
|
{
|
|
Attribute? attribute = fieldInfo.GetCustomAttribute(typeof(RemarkAttribute));
|
|
if (attribute != null)
|
|
{
|
|
return ((RemarkAttribute)attribute).GetRemark();
|
|
}
|
|
}
|
|
|
|
return value.ToString();
|
|
}
|
|
} |