public void Generate(StructureDefinition structure) { if (structure.Differential == null) throw Error.Argument("structure", "structure does not contain a differential specification"); if (!structure.IsConstraint) throw Error.Argument("structure", "structure is not a constraint or extension"); if(structure.Base == null) throw Error.Argument("structure", "structure is a constraint, but no base has been specified"); var differential = structure.Differential; var baseStructure = _resolver.GetStructureDefinition(structure.Base); if (baseStructure == null) throw Error.InvalidOperation("Could not locate the base StructureDefinition for url " + structure.Base); if (baseStructure.Snapshot == null) throw Error.InvalidOperation("Snapshot generator required the base at {0} to have a snapshot representation", structure.Base); var snapshot = (StructureDefinition.SnapshotComponent)baseStructure.Snapshot.DeepCopy(); generateBaseElements(snapshot.Element); var snapNav = new ElementNavigator(snapshot.Element); // Fill out the gaps (mostly missing parents) in the differential representation var fullDifferential = new DifferentialTreeConstructor(differential.Element).MakeTree(); var diffNav = new ElementNavigator(fullDifferential); merge(snapNav, diffNav); structure.Snapshot = new StructureDefinition.SnapshotComponent() { Element = snapNav.ToListOfElements() }; }
public void Generate(StructureDefinition structure) { if (structure.Differential == null) { throw Error.Argument("structure", "structure does not contain a differential specification"); } // [WMR 20160718] Also accept extension definitions (IsConstraint == false) if (!structure.IsConstraint && !structure.IsExtension) { throw Error.Argument("structure", "structure is not a constraint or extension"); } if (structure.Base == null) { throw Error.Argument("structure", "structure is a constraint, but no base has been specified"); } var differential = structure.Differential; var baseStructure = _resolver.GetStructureDefinition(structure.Base); if (baseStructure == null) { throw Error.InvalidOperation("Could not locate the base StructureDefinition for url " + structure.Base); } if (baseStructure.Snapshot == null) { throw Error.InvalidOperation("Snapshot generator required the base at '{0}' to have a snapshot representation", structure.Base); } var snapshot = (StructureDefinition.SnapshotComponent)baseStructure.Snapshot.DeepCopy(); generateBaseElements(snapshot.Element); var snapNav = new ElementNavigator(snapshot.Element); // Fill out the gaps (mostly missing parents) in the differential representation var fullDifferential = new DifferentialTreeConstructor(differential.Element).MakeTree(); var diffNav = new ElementNavigator(fullDifferential); merge(snapNav, diffNav); structure.Snapshot = new StructureDefinition.SnapshotComponent() { Element = snapNav.ToListOfElements() }; }
/// <summary>Create a valid tree structure from a sparse differential element list by adding missing parent element definitions.</summary> /// <returns>A tree structure representing the differential component.</returns> /// <remarks>This method returns a new list of element definitions. The input elements list is not modified.</remarks> public static List <ElementDefinition> MakeTree(List <ElementDefinition> elements) { var dtc = new DifferentialTreeConstructor(elements); return(dtc.makeTree()); }