Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/Hl7.Fhir.Base/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>F:Hl7.Fhir.Model.Resource.SyncLock</Target>
<Left>lib/net8.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>F:Hl7.Fhir.Serialization.FhirJsonException.INCOMPATIBLE_SIMPLE_VALUE_CODE</Target>
Expand Down Expand Up @@ -316,6 +323,13 @@
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Model.Resource.get_HasVersionId</Target>
<Left>lib/net8.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Rest.ContentType.BuildContentType(Hl7.Fhir.Rest.ResourceFormat,System.String)</Target>
Expand Down Expand Up @@ -400,6 +414,13 @@
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Utility.AnnotatableExtensions.RemoveAnnotations``1(Hl7.Fhir.Utility.IAnnotatable)</Target>
<Left>lib/net8.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Utility.ReflectionHelper.IsTypedCollection(System.Type)</Target>
Expand Down
62 changes: 33 additions & 29 deletions src/Hl7.Fhir.Base/ElementModel/DomNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,48 @@
using System.Linq;
using System.Threading;

namespace Hl7.Fhir.ElementModel
namespace Hl7.Fhir.ElementModel;

public class DomNode<T> : IAnnotatable where T : DomNode<T>
{
public class DomNode<T> : IAnnotatable where T : DomNode<T>
{
public string Name { get; set; } = null!;
public string Name { get; set; } = null!;

private List<T>? _childList;
private List<T>? _childList;

protected List<T> ChildList
{
get => LazyInitializer.EnsureInitialized(ref _childList, () => [])!;
set => _childList = value;
}
protected List<T> ChildList
{
get => LazyInitializer.EnsureInitialized(ref _childList, () => [])!;
set => _childList = value;
}

internal IEnumerable<T> ChildrenInternal(string? name = null) =>
name == null ? ChildList : ChildList.Where(c => c.Name.MatchesPrefix(name));
internal IEnumerable<T> ChildrenInternal(string? name = null) =>
name == null ? ChildList : ChildList.Where(c => c.Name.MatchesPrefix(name));

public T? Parent { get; protected set; }
public T? Parent { get; protected set; }

public DomNodeList<T> this[string name] => new (ChildrenInternal(name));
public DomNodeList<T> this[string name] => new (ChildrenInternal(name));

public T this[int index] => ChildList[index];
public T this[int index] => ChildList[index];

#region << Annotations >>
private AnnotationList? _annotations;
protected AnnotationList AnnotationsInternal => LazyInitializer.EnsureInitialized(ref _annotations, () => [])!;
#region << Annotations >>
private AnnotationList? _annotations;
protected AnnotationList AnnotationsInternal => LazyInitializer.EnsureInitialized(ref _annotations, () => [])!;

protected bool HasAnnotations => _annotations is not null && !_annotations.IsEmpty;
protected bool HasAnnotations => _annotations is not null && !_annotations.IsEmpty;

public void AddAnnotation(object annotation)
{
AnnotationsInternal.AddAnnotation(annotation);
}
public void AddAnnotation(object annotation)
{
AnnotationsInternal.AddAnnotation(annotation);
}

public void RemoveAnnotations(Type type)
{
AnnotationsInternal.RemoveAnnotations(type);
}
#endregion
public void RemoveAnnotations(Type type)
{
AnnotationsInternal.RemoveAnnotations(type);
}
}

public virtual IEnumerable<object> Annotations(Type type) => AnnotationsInternal.Annotations(type);

#endregion


}
Loading