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.
16 lines
402 B
16 lines
402 B
using System.ComponentModel;
|
|
|
|
namespace Connected.Extensions;
|
|
|
|
public static class EnumExtensions
|
|
{
|
|
public static string ToDescriptionString(this Enum val)
|
|
{
|
|
var attributes = (DescriptionAttribute[])val.GetType().GetField(val.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false);
|
|
|
|
return attributes.Length > 0
|
|
? attributes[0].Description
|
|
: val.ToString().ToLower();
|
|
}
|
|
}
|