コード例 #1
0
        public static XElement ToXElement(this IDICOMElement el)
        {
            var xel = new XElement("DICOMElement");

            xel.Add(new XAttribute("VR", VRDictionary.GetAbbreviationFromType(el)));
            xel.Add(new XAttribute("Tag", el.Tag.CompleteID));
            xel.Add(new XAttribute("Description", TagDictionary.GetDescription(el.Tag.CompleteID)));
            //Recursively add data if seq
            if (el.IsVR(VR.Sequence))
            {
                var seq = el as Sequence;
                for (var i = 0; i < seq.Items.Count; i++)
                {
                    var item = new XElement("Item");
                    foreach (var it in seq.Items[i].Elements)
                    {
                        item.Add(it.ToXElement());
                    }
                    xel.Add(item);
                }
            }
            else // Just add data
            {
                if (el.DatType != typeof(byte))
                {
                    foreach (var d in el.DData_)
                    {
                        xel.Add(new XElement("Data", d));
                    }
                }
                else
                {
                    //If data type is byte, write hex string
                    var array = (el.DData_ as List <byte>).ToArray();
                    var hex   = ByteHelper.ByteArrayToHexString(array);
                    xel.Add(new XElement("Data", hex));
                }
            }
            return(xel);
        }
コード例 #2
0
 public override string ToString()
 {
     return(string.Format("({0},{1}) : {2}", Group, Element, TagDictionary.GetDescription(this)));
 }