internal static AssociationResponse FromPDU(AssociateAcceptPDU pdu)
        {
            var associationResponse = new AssociationResponse();

            foreach (var item in pdu.Items)
            {
                if (item is ApplicationContextItem applicationContextItem)
                {
                    var applicationContextName = Encoding.ASCII.GetString(applicationContextItem.ApplicationContextName);
                    if (applicationContextName != NetUtils.DicomApplicationContextName)
                    {
                        throw new NotSupportedException($"Unsupported application context name '{applicationContextName}'");
                    }
                }
                else if (item is PresentationContextResponseItem presentationContextItem)
                {
                    associationResponse.PresentationContextResponses.Add(PresentationContextResponse.FromItem(presentationContextItem));
                }
                else if (item is UserInformationItem userInformationItem)
                {
                    foreach (var subItem in userInformationItem.SubItems)
                    {
                        if (subItem is MaximumLengthSubItem maximumLengthSubItem)
                        {
                            associationResponse.MaxDataTransferPDULength = maximumLengthSubItem.MaximumLength;
                        }
                    }
                }
            }

            return(associationResponse);
        }
        internal static PresentationContextResponse FromItem(PresentationContextResponseItem item)
        {
            var presentationContextResponse = new PresentationContextResponse
            {
                PresentationContextID = item.PresentationContextID,
                Result = (ResultCode)item.Result
            };

            if (presentationContextResponse.Result == ResultCode.Acceptance)
            {
                presentationContextResponse.TransferSyntaxName = item.TransferSyntaxSubItem.TransferSyntaxName;
            }
            return(presentationContextResponse);
        }