/// <summary> /// Notifies the handle that a new response segment /// is available /// </summary> /// <param name="message">The complex ack message</param> /// <param name="segment">The response segment</param> public override void FeedComplexAck(ComplexAckMessage message, BufferSegment segment) { _buffers.Add(segment); if (!message.MoreFollows) { try { // TODO: Is this the best place to do this? Decoding // large requests could potentially be more time than // we want to spent in the transaction's lock using (var stream = new MultiBufferStream(_buffers)) { var tagReader = new TagReader(stream); var tagReaderStream = new TagReaderStream(tagReader, Value <TAck> .Schema); var ack = Value <TAck> .Load(tagReaderStream); _source.SetResult(ack); } } catch (Exception e) { _source.SetException(new RejectException(RejectReason.InvalidTag)); } } }
public void ReadTest1() { var reader = fromHexString("00-19-01-29-40-3E-44-00-00-00-00-3F-4E-21-00-21-01-21-02-4F"); var stream = new TagReaderStream(reader, Schema); var test = TestType.Load(stream); Assert.AreEqual(test.BooleanValue, true); Assert.IsTrue(test.OptionalValue.HasValue); Assert.AreEqual(test.OptionalValue.Value, 64); Assert.AreEqual(test.ChoiceValue.Choice, TestChoice.Float); Assert.AreEqual(((FloatChoice)test.ChoiceValue).Value, 0.00); Assert.AreEqual(test.ArrayValue.Length, 3); for (int i = 0; i < test.ArrayValue.Length; i++) { Assert.AreEqual(test.ArrayValue[i], (ushort)i); } }