Skip to content

Commit

Permalink
Merge pull request #2991 from FirelyTeam/spike/implement-sourcenode-o…
Browse files Browse the repository at this point in the history
…n-base

Implement ISourceNode on Base
  • Loading branch information
ewoutkramer authored Dec 10, 2024
2 parents a73ae97 + 9d002d6 commit 3c875c2
Show file tree
Hide file tree
Showing 31 changed files with 443 additions and 335 deletions.
4 changes: 4 additions & 0 deletions src/Benchmarks/SerializationBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ public string XmlDictionarySerializer()
[Benchmark]
public string TypedElementSerializerJson()
{
#pragma warning disable SDK0001
return Patient.ToTypedElement().ToJson();
#pragma warning restore SDK0001
}

[Benchmark]
public string TypedElementSerializerXml()
{
#pragma warning disable SDK0001
return Patient.ToTypedElement().ToXml();
#pragma warning restore SDK0001
}
}
}
12 changes: 9 additions & 3 deletions src/Hl7.Fhir.Base/ElementModel/PocoBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
using Hl7.Fhir.Introspection;
using Hl7.Fhir.Model;
using Hl7.Fhir.Serialization;
using Hl7.Fhir.Utility;
using System;
using System.Diagnostics.CodeAnalysis;

namespace Hl7.Fhir.ElementModel
{
Expand All @@ -28,8 +30,12 @@ public static T ToPoco<T>(this ITypedElement element, ModelInspector inspector,
public static Base ToPoco(this ITypedElement element, ModelInspector inspector, PocoBuilderSettings settings = null) =>
new NewPocoBuilder(inspector, settings ?? new PocoBuilderSettings()).BuildFrom(element);

public static ISourceNode ToSourceNode(this Base @base, ModelInspector inspector, string rootName = null) =>
@base.ToTypedElement(inspector, rootName).ToSourceNode();

public static ISourceNode ToSourceNode(this Base @base, ModelInspector inspector, string rootName = null)
{
var node = @base.ToElementNode(rootName);
((IAnnotatable)node).AddAnnotation(inspector);

return node;
}
}
}
211 changes: 0 additions & 211 deletions src/Hl7.Fhir.Base/ElementModel/PocoElementNode2.cs

This file was deleted.

Loading

0 comments on commit 3c875c2

Please sign in to comment.