protected static ITypedElement MakeElementStack(Base instance, SummaryType summary) { if (summary == SummaryType.False) { return(instance.ToTypedElement()); } var patchedInstance = (Base)instance.DeepCopy(); MetaSubsettedAdder.AddSubsetted(patchedInstance, atRoot: true); var baseNav = new ScopedNode(patchedInstance.ToTypedElement()); switch (summary) { case SummaryType.True: return(MaskingNode.ForSummary(baseNav)); case SummaryType.Text: return(MaskingNode.ForText(baseNav)); case SummaryType.Data: return(MaskingNode.ForData(baseNav)); case SummaryType.Count: return(MaskingNode.ForCount(baseNav)); default: return(baseNav); } }
public void SummaryCountUsingStructureDefinitionSummaryProvider() { var tpXml = File.ReadAllText(Path.Combine("TestData", "mask-text.xml")); var nav = new ScopedNode(getXmlNodeSDSP(tpXml)); var masker = MaskingNode.ForCount(nav); var maskedChildren = masker.Descendants().Count(); Assert.AreEqual(maskedChildren, 2); ITypedElement getXmlNodeSDSP(string xml, FhirXmlParsingSettings s = null) => XmlParsingHelpers.ParseToTypedElement(xml, new StructureDefinitionSummaryProvider(ZipSource.CreateValidationSource()), s); }
protected static ITypedElement MakeElementStack(Base instance, SummaryType summary, string[] elements) { if (summary == SummaryType.False && elements == null) { return(instance.ToTypedElement()); } if (elements != null && summary != SummaryType.False) { throw Error.Argument("elements", "Elements parameter is supported only when summary is SummaryType.False or summary is not specified at all."); } var patchedInstance = (Base)instance.DeepCopy(); MetaSubsettedAdder.AddSubsetted(patchedInstance, atRoot: true); var baseNav = new ScopedNode(patchedInstance.ToTypedElement()); switch (summary) { case SummaryType.True: return(MaskingNode.ForSummary(baseNav)); case SummaryType.Text: return(MaskingNode.ForText(baseNav)); case SummaryType.Data: return(MaskingNode.ForData(baseNav)); case SummaryType.Count: return(MaskingNode.ForCount(baseNav)); case SummaryType.False: return(MaskingNode.ForElements(baseNav, elements)); default: return(baseNav); } }