2016-06-27 01:45:38 +02:00
|
|
|
|
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());
|
2025-03-25 17:36:15 +01:00
|
|
|
|
var attributes = (DescriptionAttribute[]) fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
2016-06-27 01:45:38 +02:00
|
|
|
|
|
|
|
|
|
|
return attributes.Length > 0 ? attributes[0].Description : value.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|