public static void WritePresentationCtxRequestType(DICOMBinaryWriter dw, PresentationContext pc) { dw.Write((byte)ItemType.PRESENTATION_CONTEXT_REQUEST); dw.WriteNullBytes(1); //Reserved Null Byte byte[] internBytes; //Will use to get length using (var stream = new MemoryStream()) { using (var intern = new DICOMBinaryWriter(stream)) { intern.Write((byte)pc.Id); intern.WriteNullBytes(1); intern.Write((byte)pc.Reason); intern.WriteNullBytes(1); WriteAbstractSyntax(intern, pc.AbstractSyntax); foreach (var syntax in pc.TransferSyntaxes) { WriteTransferSyntax(intern, syntax); } internBytes = stream.ToArray(); } } LengthWriter.WriteBigEndian(dw, internBytes.Length, 2); dw.Write(internBytes); }
private byte[] WriteBody() { var body = new byte[0]; var stream = new MemoryStream(); using (var dw = new DICOMBinaryWriter(stream)) { //Main body LengthWriter.WriteBigEndian(dw, ProtocolVersion, 2); //Protocol Version dw.WriteNullBytes(2); //Reserved Null bytes dw.Write(CalledEntityTitle.PadRight(16)); dw.Write(CallingEntityTitle.PadRight(16)); dw.WriteNullBytes(32); //Reserved Null bytes ItemWriter.WriteApplicationContext(dw, ApplicationContext); foreach (PresentationContext pc in PresentationContexts) { ItemWriter.WritePresentationCtxAcceptType(dw, pc); } ItemWriter.WriteUserInfo(dw, UserInfo); body = stream.ToArray(); } return(body); }