internal static PresentationContextRequest FromItem(PresentationContextRequestItem item) { var presentationContextRequest = new PresentationContextRequest { PresentationContextID = item.PresentationContextID }; foreach (var subItem in item.SubItems) { if (subItem is AbstractSyntaxSubItem abstractSyntaxSubItem) { presentationContextRequest.AbstractSyntaxName = abstractSyntaxSubItem.AbstractSyntaxName; } else if (subItem is TransferSyntaxSubItem transferSyntaxSubItem) { presentationContextRequest.TransferSyntaxNames.Add(transferSyntaxSubItem.TransferSyntaxName); } } return(presentationContextRequest); }
internal static AssociationRequest FromPDU(AssociateRequestPDU pdu) { var associationRequest = new AssociationRequest { CalledAETitle = NetUtils.ReadAsciiStringFrom(pdu.CalledAETitle), CallingAETitle = NetUtils.ReadAsciiStringFrom(pdu.CallingAETitle) }; 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 PresentationContextRequestItem presentationContextItem) { associationRequest.PresentationContextRequests.Add(PresentationContextRequest.FromItem(presentationContextItem)); } else if (item is UserInformationItem userInformationItem) { foreach (var subItem in userInformationItem.SubItems) { if (subItem is MaximumLengthSubItem maximumLengthSubItem) { associationRequest.MaxDataTransferPDULength = maximumLengthSubItem.MaximumLength; } } } } return(associationRequest); }