Currently I building a small desktop application that can handle DICOM files. I am coding in C# and .NET and using the ClearCanvas library. One thing that I need to do is to be able to display the full contents of the file including all of the sequences. But the sequences are done in a recursive manner, so each sequence can have more sequences inside of it. Right now my code can access the first two levels, but I am just doing this as a tester, since I need to be able to access the nth level of sequences. So I need to somehow automate this. This is what my code looks like right now for the first two levels.
DicomSequenceItem[] seq = attrs2[i].Values as DicomSequenceItem[];
if (seq != null)
{
for (int j = 0; j < seq.Length; j++)
{
for (int n = 0; n < seq[j].Count; n++)
{
DicomSequenceItem[] level2 = seq[j].ElementAt(n).Values as DicomSequenceItem[];
if(seq[j].ElementAt(n).GetValueType().ToString().Equals("ClearCanvas.Dicom.DicomSequenceItem"))
{
for (int k = 0; k < level2.Length; k++)
{
for (int l = 0; l < level2[k].Count; l++)
{
text += "\t\t" + level2[k].ElementAt(l) + "\r\n";
}
}
}
else
{
text += "\t" + seq[j].ElementAt(n) + "\r\n";
}
}
}
}
Any help (code samples) would be greatly appreciated.
Thanks!