123456789101112131415161718192021 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ShakerManger.Tools
- {
- internal static class EnumHelper
- {
- public static string Description(this Enum e)
- {
- if (e == null || !e.GetType().IsEnum) return "";
- return (e.GetType()?
- .GetField(e.ToString())?
- .GetCustomAttributes(typeof(DescriptionAttribute), false)
- .FirstOrDefault() as DescriptionAttribute)?.Description ?? e.ToString();
- }
- }
- }
|