public static Message <PDataTF> ReadPDFData(NetworkBinaryReader dr, bool firstByteRead = false, int i = 0) { PDataTF pdata = null; pdata = new PDataTF(); if (!firstByteRead) { dr.Skip(1); } dr.Skip(1); // PDU ID and Reserved Null Byte var lengthBytes = dr.Take(4); int length = LengthReader.ReadBigEndian(lengthBytes); using (DICOMBinaryReader dbr = dr.GetSubStream(length)) { while (dbr.StreamPosition < dbr.StreamLength) { PDVItem item = ItemReader.ReadPDVItem(dbr); pdata.Items.Add(item); } } return(new Message <PDataTF> { Payload = pdata, Type = MessageType.PDATA_TF }); }