Example #1
0
        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);
            }
        }
Example #2
0
        public void Summary()
        {
            var tpXml     = File.ReadAllText(Path.Combine("TestData", "fp-test-patient.xml"));
            var typeinfo  = new PocoStructureDefinitionSummaryProvider().Provide("Patient");
            var inSummary = typeinfo.GetElements().Where(e => e.InSummary).ToList();

            var nav    = new ScopedNode(getXmlNode(tpXml));
            var masker = MaskingNode.ForSummary(nav);
            var output = masker.ToXml();

            var maskedChildren = masker.Children().ToList();

            Assert.IsTrue(maskedChildren.Count < inSummary.Count);
            Assert.IsTrue(maskedChildren.Select(c => c.Name).All(c => inSummary.Any(s => s.ElementName == c)));
        }
Example #3
0
        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);
            }
        }