Пример #1
0
        public SDTreeNode GenerateDifferentialTree()
        {
            SDTreeNode snapshotTree = GenerateSnapshotTree(true);

            snapshotTree.DepthFirstTreeWalk(t => RemoveUnchangedNodes(t));

            return(snapshotTree);
        }
Пример #2
0
        public SDTreeNode GenerateSnapshotTree(bool includeNodesWithZeroMaxCardinality = true)
        {
            // process ElementDefinition list
            //
            // to create list where path values are unique (by indexing slices)
            // and where there are no orphan children by creating fake parents
            //

            ElementDefinition[] elements = _structureDefinition.differential.element;

            // mark elements as changed
            foreach (ElementDefinition element in elements)
            {
                element.HasChangedFromBase = true;
            }

            // sanity checks
            PerformDifferentialElementsSanityCheck(elements, false);

            // populate ElementDefinitions with their ancestor ElementDefinition
            PopulateBaseElementDefinitions(elements);

            // "index" slices to create unique ElementDefinition.path values
            IndexSlices(elements);

            // Merge differential and the direct base StructureDefinition's differential. -- this needs expanding to include all ancestor base StructureDefinitions
            elements = CreateSnapshot(_structureDefinition);

            // Add fake missing parents
            elements = AddFakeMissingParents(elements);

            // build tree
            //
            //

            SDTreeNode rootNode = GenerateTree(elements);

            // process tree
            //
            //

            // Expand out data types
            rootNode.DepthFirstTreeWalk(t => AddMissingComplexDataTypeElements(t));

            // group slices under the slice "setup" node (except extension slices)
            rootNode.DepthFirstTreeWalk(t => GroupSlices(t));

            // remove 0..0 nodes and their children
            if (!includeNodesWithZeroMaxCardinality)
            {
                rootNode.DepthFirstTreeWalk(t => RemoveZeroMaxCardinalityNodes(t));
            }

            // remove setup extension "setup" slice nodes
            rootNode.DepthFirstTreeWalk(t => RemoveExtensionSetupSlices(t));

            // add extension definitions
            rootNode.DepthFirstTreeWalk(t => AddExtensionDefinitions(t, _resolver));

            // group children of slice parent not part of numbered slice
            rootNode.DepthFirstTreeWalk(t => GroupOpenSliceElements(t));

            return(rootNode);
        }