internal AssociateAcceptPDU ToPDU(AssociateRequestPDU requestPDU)
        {
            var pdu = new AssociateAcceptPDU();

            requestPDU.CalledAETitle.AsSpan().CopyTo(pdu.CopiedFromAssociateRequestPDU_1);
            requestPDU.CallingAETitle.AsSpan().CopyTo(pdu.CopiedFromAssociateRequestPDU_2);
            requestPDU.Reserved.AsSpan().CopyTo(pdu.CopiedFromAssociateRequestPDU_3);

            pdu.Items.Add(new ApplicationContextItem
            {
                ApplicationContextName = Encoding.ASCII.GetBytes(NetUtils.DicomApplicationContextName)
            });

            foreach (var presentationContextResponse in PresentationContextResponses)
            {
                pdu.Items.Add(presentationContextResponse.ToItem());
            }

            var userInformationItem = new UserInformationItem();

            if (MaxDataTransferPDULength.HasValue)
            {
                userInformationItem.SubItems.Add(new MaximumLengthSubItem
                {
                    MaximumLength = MaxDataTransferPDULength.Value
                });
            }

            pdu.Items.Add(userInformationItem);

            return(pdu);
        }
        internal AssociateRequestPDU ToPDU()
        {
            var pdu = new AssociateRequestPDU();

            NetUtils.WriteAsciiStringTo(CalledAETitle, pdu.CalledAETitle);

            NetUtils.WriteAsciiStringTo(CallingAETitle, pdu.CallingAETitle);

            pdu.Items.Add(new ApplicationContextItem
            {
                ApplicationContextName = Encoding.ASCII.GetBytes(NetUtils.DicomApplicationContextName)
            });

            foreach (var presentationContextRequest in PresentationContextRequests)
            {
                pdu.Items.Add(presentationContextRequest.ToItem());
            }

            var userInformationItem = new UserInformationItem();

            if (MaxDataTransferPDULength.HasValue)
            {
                userInformationItem.SubItems.Add(new MaximumLengthSubItem
                {
                    MaximumLength = MaxDataTransferPDULength.Value
                });
            }

            pdu.Items.Add(userInformationItem);

            return(pdu);
        }