/// <inheritdoc /> public override int Deserialize(Core.Utility.BinaryReader reader) { var responseBuffer = new byte[UniqueIdSize]; var numRead = reader.Read(responseBuffer, 0, UniqueIdSize); var lowPart = System.BitConverter.ToUInt64(responseBuffer, 0); var highPart = System.BitConverter.ToUInt64(responseBuffer, 8); UniqueId = highPart.ToString("X16") + lowPart.ToString("X16"); var lowStatusBits = (DeviceStatusFlagsLo)reader.ReadUInt64(); var highStatusBits = (DeviceStatusFlagsHi)reader.ReadUInt64(); DeviceStatusFlags = new Model.DeviceStatusFlags(lowStatusBits, highStatusBits); numRead += StatusBytesSize; // TODO: throw here? System.Diagnostics.Debug.Assert(numRead == DeserializeByteCount, "Failed to deserialize correct number of bytes in DeviceStatusResponse."); return(numRead); }
/// <inheritdoc/> protected override int DeserializePayload(Core.Utility.BinaryReader reader) { // Verify we're not going to be truncated. if ((reader.BaseStream.Length - reader.BaseStream.Position) < Length) { throw new System.IO.EndOfStreamException(); } // Get the clear portion of the key - the DRUID. var responseBuffer = new byte[UniqueIdSize]; reader.Read(responseBuffer, 0, UniqueIdSize); var lowPart = System.BitConverter.ToUInt64(responseBuffer, 0); var highPart = System.BitConverter.ToUInt64(responseBuffer, 8); UniqueId = highPart.ToString("X16") + lowPart.ToString("X16"); // Skip past the rest of it - we've got all we care about. reader.BaseStream.Seek(Length - UniqueIdSize, System.IO.SeekOrigin.Current); // NOTE: Scrambled blocks *CANNOT* be validated by a CRC check! return(Length); }