refactor(AnnotationParams): AnnotationJSObject aktualisieren, um IAnnotation (anstelle von Annotation) zu enthalten

- Hintergrund in AnnotationJSObject hinzufügen, wenn er nicht null ist
This commit is contained in:
Developer 02
2025-04-23 17:25:58 +02:00
parent e95d1d782e
commit e72ea534e5
2 changed files with 21 additions and 3 deletions

View File

@@ -6,11 +6,12 @@ public class AnnotationParams
{
public AnnotationParams()
{
_AnnotationJSObjectInitor = new(() => _annots.ToDictionary(a => a.Name.ToLower(), a => a));
_AnnotationJSObjectInitor = new(CreateAnnotationJSObject);
}
public Background? Background { get; init; }
#region Annotation
[JsonIgnore]
public Annotation? DefaultAnnotation { get; init; }
@@ -55,8 +56,21 @@ public class AnnotationParams
}
}
}
#endregion
private readonly Lazy<Dictionary<string, Annotation>> _AnnotationJSObjectInitor;
#region AnnotationJSObject
private Dictionary<string, IAnnotation> CreateAnnotationJSObject()
{
var dict = _annots.ToDictionary(a => a.Name.ToLower(), a => a as IAnnotation);
public Dictionary<string, Annotation> AnnotationJSObject => _AnnotationJSObjectInitor.Value;
if (Background is not null)
dict.Add(Background.Name.ToLower(), Background);
return dict;
}
private readonly Lazy<Dictionary<string, IAnnotation>> _AnnotationJSObjectInitor;
public Dictionary<string, IAnnotation> AnnotationJSObject => _AnnotationJSObjectInitor.Value;
#endregion
}