Beispiel #1
0
        public override T Get <T>(int item = -1)
        {
            if (_values == null)
            {
                _values = base.Get <string[]>().Select(x => DicomUID.Parse(x)).ToArray();
            }

            if (typeof(T) == typeof(DicomTransferSyntax))
            {
                return((T)(object)DicomTransferSyntax.Lookup(_values[item]));
            }

            if (typeof(T) == typeof(DicomTransferSyntax[]))
            {
                return((T)(object)_values.Select(x => DicomTransferSyntax.Lookup(x)).ToArray());
            }

            if (typeof(T) == typeof(DicomUID) || typeof(T) == typeof(object))
            {
                return((T)(object)_values[item]);
            }

            if (typeof(T) == typeof(DicomUID[]) || typeof(T) == typeof(object[]))
            {
                return((T)(object)_values);
            }

            return(base.Get <T>(item));
        }
        private void LookupReturnsKnownTransferSyntax()
        {
            var ts = DicomTransferSyntax.Lookup(DicomUID.ImplicitVRLittleEndian);

            Assert.NotNull(ts);
            Assert.Equal(DicomUID.ImplicitVRLittleEndian, ts.UID);
        }
        private void LookupThrowsOnInvalidUidType()
        {
            var uid = DicomUID.ComputedRadiographyImageStorage;

            Assert.Throws <DicomDataException>(
                () => DicomTransferSyntax.Lookup(uid)
                );
        }
        private void LookupReturnsAdHocTransferSyntax()
        {
            var uid = new DicomUID("0", "testing", DicomUidType.TransferSyntax);

            var ts = DicomTransferSyntax.Lookup(uid);

            Assert.NotNull(ts);
            Assert.Equal(uid, ts.UID);

            //  Lookup must not auto-register, as it is invoked from DicomServer.
            //  auto-registration may cause DoS by sending crafted transfer syntaxes repeatedly,
            //  which causes internal static dictionary to hold all the transfer syntaxes.
            Assert.Null(DicomTransferSyntax.Query(uid));
        }