Example #1
0
        /// <summary>
        /// Compares a list of transfer syntaxes accepted by the SCP against the list of transfer syntaxes proposed by the SCU. Sets the presentation 
        /// context <c>Result</c> to <c>DicomPresentationContextResult.Accept</c> if an accepted transfer syntax is found. If no accepted transfer
        /// syntax is found, the presentation context <c>Result</c> is set to <c>DicomPresentationContextResult.RejectTransferSyntaxesNotSupported</c>.
        /// </summary>
        /// <param name="acceptedTransferSyntaxes">Transfer syntaxes that the SCP accepts for the proposed abstract syntax.</param>
        /// <param name="scpPriority">If set to <c>true</c>, transfer syntaxes will be accepted in the order specified by <paramref name="acceptedTransferSyntaxes"/>. If set to <c>false</c>, transfer syntaxes will be accepted in the order proposed by the SCU.</param>
        /// <returns>Returns <c>true</c> if an accepted transfer syntax was found. Returns <c>false</c> if no accepted transfer syntax was found.</returns>
        public bool AcceptTransferSyntaxes(DicomTransferSyntax[] acceptedTransferSyntaxes, bool scpPriority = false)
        {
            if (Result == DicomPresentationContextResult.Accept) return true;

            if (scpPriority)
            {
                // let the SCP decide which syntax that it would prefer
                foreach (DicomTransferSyntax ts in acceptedTransferSyntaxes)
                {
                    if (ts != null && HasTransferSyntax(ts))
                    {
                        SetResult(DicomPresentationContextResult.Accept, ts);
                        return true;
                    }
                }
            }
            else
            {
                // accept syntaxes in the order that the SCU proposed them
                foreach (DicomTransferSyntax ts in _transferSyntaxes)
                {
                    if (acceptedTransferSyntaxes.Contains(ts))
                    {
                        SetResult(DicomPresentationContextResult.Accept, ts);
                        return true;
                    }
                }
            }

            SetResult(DicomPresentationContextResult.RejectTransferSyntaxesNotSupported);

            return false;
        }