18 lines
508 B
C#
18 lines
508 B
C#
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;
|
|
}
|
|
}
|
|
}
|
|
|