添加项目文件。
This commit is contained in:
17
ExportExcelTest/Models/EnumExtensions.cs
Normal file
17
ExportExcelTest/Models/EnumExtensions.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
|
||||
namespace CustomOpenAddins.Models
|
||||
{
|
||||
static class EnumExtensions
|
||||
{
|
||||
public static string GetDescription(this Enum val)
|
||||
{
|
||||
var field = val.GetType().GetField(val.ToString());
|
||||
var customAttribute = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute));
|
||||
return customAttribute == null ? val.ToString() : ((DescriptionAttribute)customAttribute).Description;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user