-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathUtils.cs
More file actions
23 lines (20 loc) · 687 Bytes
/
Copy pathUtils.cs
File metadata and controls
23 lines (20 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GBFRDataTools.FSM;
public static class Utils
{
public static string GetEnumDescription(Enum value)
{
if (value == null)
return string.Empty;
var type = value.GetType();
var field = type.GetField(value.ToString());
var custAttr = field?.GetCustomAttributes(typeof(DescriptionAttribute), false);
DescriptionAttribute? attribute = custAttr?.SingleOrDefault() as DescriptionAttribute;
return attribute == null ? value.ToString() : attribute.Description;
}
}