17 lines
449 B
C#
17 lines
449 B
C#
using System;
|
|
using System.ComponentModel;
|
|
|
|
namespace BS.Shared.Extensions
|
|
{
|
|
public static class EnumExtensions
|
|
{
|
|
public static string GetEnumDescription(this Enum value)
|
|
{
|
|
var fi = value.GetType().GetField(value.ToString());
|
|
var attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
|
|
|
return attributes.Length > 0 ? attributes[0].Description : value.ToString();
|
|
}
|
|
}
|
|
}
|