Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
LdsVersionNumber.cs
1using System.Diagnostics.CodeAnalysis;
2using System.Text;
4
6{
10 public class LdsVersionNumber : DataObject
11 {
16 : base([])
17 {
18 }
19
26 public LdsVersionNumber(byte[] Value, int MajorVersion, int MinorVersion)
27 : base(Value)
28 {
29 this.MajorVersion = MajorVersion;
30 this.MinorVersion = MinorVersion;
31 }
32
36 public override ushort Tag => 0x5f01;
37
41 public int MajorVersion { get; }
42
46 public int MinorVersion { get; }
47
55 public override bool TryParse(byte[] Value, TravelDocumentsClient Client,
56 [NotNullWhen(true)] out IDataObject? Parsed)
57 {
58 if (Value.Length == 4)
59 {
60 string MajorVersion = TrimLeadingZeroes(Encoding.ASCII.GetString(Value, 0, 2));
61 string MinorVersion = TrimLeadingZeroes(Encoding.ASCII.GetString(Value, 2, 2));
62
63 Client.Information("LDS version: " + MajorVersion + "." + MinorVersion);
64
65 if (int.TryParse(MajorVersion, out int MajorVersionInt) &&
66 int.TryParse(MinorVersion, out int MinorVersionInt))
67 {
68 Parsed = new LdsVersionNumber(Value, MajorVersionInt, MinorVersionInt);
69 return true;
70 }
71 }
72 else
73 Client.Warning("LDS version: " + Hashes.BinaryToString(Value));
74
75 Parsed = null;
76 return false;
77 }
78 }
79}
LdsVersionNumber(byte[] Value, int MajorVersion, int MinorVersion)
LDS Version Number
override bool TryParse(byte[] Value, TravelDocumentsClient Client, [NotNullWhen(true)] out IDataObject? Parsed)
Tries to parse a binary representation of the data object.
Contains methods for simple hash calculations.
Definition: Hashes.cs:57
static string BinaryToString(byte[] Data)
Converts an array of bytes to a string with their hexadecimal representations (in lower case).
Definition: Hashes.cs:63