public Profile Expand(Profile differential) { // Start by making a full copy of the differential var snapshot = (Profile)differential.DeepCopy(); // Assure there's a text element, even if there's none in the differential if (snapshot.Text == null) { snapshot.Text = new Narrative() { Status = Narrative.NarrativeStatus.Empty }; snapshot.Text.Div = "<div xmlns='http://www.w3.org/1999/xhtml'>No narrative was supplied for this Profile</div>"; } // We leave the globally defined Queries, Extensions and Mappings alone, the // only thing we expand are the Structures if (snapshot.Structure != null) { var differentialStructures = snapshot.Structure.ToList(); foreach (var differentialStructure in differentialStructures) { // keep the differential form in the snapshot profile, as an unpublished copy //stashDifferentialStructure(snapshot, differentialStructure); // Instead of keeping it, remove the original differential form snapshot.Structure.Remove(differentialStructure); // add the expanded differential structure in the new snapshot form snapshot.Structure.Add( expandStructure(differentialStructure) ); } } finalizeExtensions(snapshot); return snapshot; }
private Profile.ElementComponent createExtensionSlicingEntry(string path, Profile.ElementComponent template) { // Create a pre-fab extension slice, filled with sensible defaults // Extensions will repeat their definitions in their slicing entry var result = (Profile.ElementComponent)template.DeepCopy(); //var result = new Profile.ElementComponent(); //result.Path = path; result.Slicing = new Profile.ElementSlicingComponent(); result.Slicing.Discriminator = new[] {"url"}; result.Slicing.Ordered = false; result.Slicing.Rules = Profile.SlicingRules.Open; return result; }