Exemplo n.º 1
0
    public static void RecurseDataSet(File f, DataSet ds, string indent)
    {
        CSharpDataSet cds = new CSharpDataSet(ds);

        while (!cds.IsAtEnd())
        {
            DataElement de = cds.GetCurrent();
            // Compute VR from the toplevel file, and the currently processed dataset:
            VR vr = DataSetHelper.ComputeVR(f, ds, de.GetTag());

            if (vr.Compatible(new VR(VR.VRType.SQ)))
            {
                uint uvl = (uint)de.GetVL();                                           // Test cast is ok
                System.Console.WriteLine(indent + de.GetTag().toString() + ":" + uvl); // why not ?
                //SequenceOfItems sq = de.GetSequenceOfItems();
                // GetValueAsSQ handle more cases than GetSequenceOfItems
                SmartPtrSQ sq = de.GetValueAsSQ();
                uint       n  = sq.GetNumberOfItems();
                for (uint i = 1; i <= n; i++) // item starts at 1, not 0
                {
                    Item    item   = sq.GetItem(i);
                    DataSet nested = item.GetNestedDataSet();
                    RecurseDataSet(f, nested, indent + "  ");
                }
            }
            else
            {
                System.Console.WriteLine(indent + de.toString());
            }
            cds.Next();
        }
    }