We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1405dd2 commit 1164350Copy full SHA for 1164350
src/S7CommPlusDriver/Net/Error.cs
@@ -0,0 +1,23 @@
1
+using System.Collections.Generic;
2
+using System.Linq;
3
+
4
+namespace S7CommPlusDriver.Net
5
+{
6
+ public class Error
7
+ {
8
+ private static readonly Dictionary<int, string> errorsDictionary;
9
10
+ static Error()
11
12
+ var fields = typeof(S7Consts).GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
13
+ errorsDictionary = fields.Where(x => x.Name.StartsWith("err")).ToDictionary(x => (int)x.GetValue(null), x => x.Name);
14
+ }
15
16
+ public static string GetErrorText(int error)
17
18
+ if (errorsDictionary.TryGetValue(error, out var text))
19
+ return text;
20
+ return null;
21
22
23
+}
0 commit comments