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.Reflection;
|
| namespace IStation.Epanet.Enums
| {
| public static class Error
| {
| public static string GetMsg(this ErrorCode errorCode)
| {
| FieldInfo field;
| Type t = typeof(ErrorCode);
| if (t.IsEnum
| && (field = t.GetField(errorCode.ToString())) != null
| && Attribute.GetCustomAttribute(field, typeof(ErrorAttribute)) is ErrorAttribute att
| && att.Msg != null)
| {
| return att.Msg;
| }
|
| return string.Empty;
| }
|
| }
| }
|
|