コード例 #1
0
ファイル: DicomElement.cs プロジェクト: zhan2016/fo-dicom
        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));
        }
コード例 #2
0
 /// <summary>
 /// Get the transfer syntax from the specified <paramref name="uid"/> string.
 /// </summary>
 /// <param name="uid">String representing transfer syntax UID.</param>
 /// <returns><see cref="DicomTransferSyntax"/> object corresponding to <paramref name="uid"/>.</returns>
 /// <remarks><see cref="Parse"/> is a wrapper around <see cref="Lookup"/> for string based <paramref name="uid"/>.</remarks>
 public static DicomTransferSyntax Parse(string uid)
 {
     if (uid == null)
     {
         throw new ArgumentNullException(nameof(uid));
     }
     return(Lookup(DicomUID.Parse(s: uid, type: DicomUidType.TransferSyntax)));
 }
コード例 #3
0
        public void CanParseStringWithTrailingBlank()
        {
            var uid = DicomUID.Parse("1.2.3.4.5.6.7.8.9.0 ");

            Assert.Equal("Unknown", uid.Name);
            Assert.Equal("1.2.3.4.5.6.7.8.9.0", uid.UID);
            Assert.Equal(DicomUidType.Unknown, uid.Type);
        }
コード例 #4
0
        public void CanParseGeneric()
        {
            var uid = DicomUID.Parse <DicomUID>("1.2.3.4.5.6.7.8.9.0");

            Assert.Equal("Unknown", uid.Name);
            Assert.Equal("1.2.3.4.5.6.7.8.9.0", uid.UID);
            Assert.Equal(DicomUidType.Unknown, uid.Type);
        }
コード例 #5
0
        public void CanParseWithNameAndType()
        {
            var uid = DicomUID.Parse(s: "1.2.3.4.5.6.7.8.9.0", name: "UidName", type: DicomUidType.TransferSyntax);

            Assert.Equal("UidName", uid.Name);
            Assert.Equal("1.2.3.4.5.6.7.8.9.0", uid.UID);
            Assert.Equal(DicomUidType.TransferSyntax, uid.Type);
        }
コード例 #6
0
        public void CanParseWithName()
        {
            var uid = DicomUID.Parse(s: "1.2.3.4.5.6.7.8.9.0", name: "UidName");

            Assert.Equal("UidName", uid.Name);
            Assert.Equal("1.2.3.4.5.6.7.8.9.0", uid.UID);
            Assert.Equal(DicomUidType.Unknown, uid.Type);
        }
コード例 #7
0
        public void PrivateInformationCreatorUID_SetterGetter_DataIsMaintained()
        {
            var inFile   = DicomFile.Open(@"Test Data\CT-MONO2-16-ankle");
            var expected = "1.2.3";

            inFile.FileMetaInfo.PrivateInformationCreatorUID = DicomUID.Parse(expected);

            using (var saveStream = new MemoryStream())
            {
                inFile.Save(saveStream);
                saveStream.Seek(0, SeekOrigin.Begin);

                var file = DicomFile.Open(saveStream);
                Assert.Equal(expected, file.FileMetaInfo.PrivateInformationCreatorUID.UID);
            }
        }
コード例 #8
0
 public static DicomTransferSyntax Parse(string uid)
 {
     return(Lookup(DicomUID.Parse(uid)));
 }