Beispiel #1
0
        private static SourceNode buildNode(ISourceNode node, bool recursive, IEnumerable <Type> annotationsToCopy)
        {
            var me = new SourceNode(node.Name, node.Text);

            var rts = node.Annotation <IResourceTypeSupplier>();

            if (rts != null)
            {
                me.ResourceType = rts.ResourceType;
            }

            foreach (var t in annotationsToCopy ?? Enumerable.Empty <Type>())
            {
                foreach (var ann in node.Annotations(t))
                {
                    me.AddAnnotation(ann);
                }
            }

            if (recursive)
            {
                me.AddRange(node.Children().Select(c => buildNode(c, recursive: true, annotationsToCopy: annotationsToCopy)));
            }

            return(me);
        }
Beispiel #2
0
        public void KeepsAnnotations()
        {
            ISourceNode firstIdNode = patient[1][0];

            Assert.Equal("a string annotation", firstIdNode.Annotation <string>());
            Assert.Equal("a string annotation", patient["active"]["id"].First().Annotation <string>());
        }
        public XDocument Build(ISourceNode source)
        {
            bool hasXmlSource = source.Annotation <FhirXmlNode>() != null;

            // We can only work with an untyped source if we're doing a roundtrip,
            // so we have all serialization details available.
            if (hasXmlSource)
            {
                _roundtripMode = true;
#pragma warning disable CS0618 // Type or member is obsolete
                return(buildInternal(source.ToTypedElement()));

#pragma warning restore CS0618 // Type or member is obsolete
            }
            else
            {
                throw Error.NotSupported($"The {nameof(FhirXmlBuilder)} will only work correctly on an untyped " +
                                         $"source if the source is a {nameof(FhirXmlNode)}.");
            }
        }
Beispiel #4
0
        public JObject Build(ISourceNode source)
        {
            bool hasJsonSource = source.Annotation <FhirJsonNode>() != null;

            // We can only work with an untyped source if we're doing a roundtrip,
            // so we have all serialization details available.
            if (hasJsonSource)
            {
                _roundtripMode = true;          // will allow unknown elements to be processed
#pragma warning disable 612,618
                return(buildInternal(source.ToTypedElement()));

#pragma warning restore 612,618
            }
            else
            {
                throw Error.NotSupported($"The {nameof(FhirJsonBuilder)} will only work correctly on an untyped " +
                                         $"source if the source is a {nameof(FhirJsonNode)}.");
            }
        }
 /// <summary>
 /// Gets the <see cref="IResourceTypeSupplier" /> annotation from an <c>ISourceNode</c>
 /// </summary>
 /// <param name="node"></param>
 public static string GetResourceTypeIndicator(this ISourceNode node) =>
 node.Annotation <IResourceTypeSupplier>()?.ResourceType;