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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user