From e72ea534e596baa16c16037d623c8076942b30a1 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Wed, 23 Apr 2025 17:25:58 +0200 Subject: [PATCH] =?UTF-8?q?refactor(AnnotationParams):=20AnnotationJSObjec?= =?UTF-8?q?t=20aktualisieren,=20um=20IAnnotation=20(anstelle=20von=20Annot?= =?UTF-8?q?ation)=20zu=20enthalten=20=20-=20Hintergrund=20in=20AnnotationJ?= =?UTF-8?q?SObject=20hinzuf=C3=BCgen,=20wenn=20er=20nicht=20null=20ist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Models/Annotation/AnnotationParams.cs | 20 ++++++++++++++++--- .../Models/Annotation/Background.cs | 4 ++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/EnvelopeGenerator.Web/Models/Annotation/AnnotationParams.cs b/EnvelopeGenerator.Web/Models/Annotation/AnnotationParams.cs index 96a3e7f9..785d7046 100644 --- a/EnvelopeGenerator.Web/Models/Annotation/AnnotationParams.cs +++ b/EnvelopeGenerator.Web/Models/Annotation/AnnotationParams.cs @@ -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> _AnnotationJSObjectInitor; + #region AnnotationJSObject + private Dictionary CreateAnnotationJSObject() + { + var dict = _annots.ToDictionary(a => a.Name.ToLower(), a => a as IAnnotation); + + if (Background is not null) + dict.Add(Background.Name.ToLower(), Background); + + return dict; + } + + private readonly Lazy> _AnnotationJSObjectInitor; - public Dictionary AnnotationJSObject => _AnnotationJSObjectInitor.Value; + public Dictionary AnnotationJSObject => _AnnotationJSObjectInitor.Value; + #endregion } diff --git a/EnvelopeGenerator.Web/Models/Annotation/Background.cs b/EnvelopeGenerator.Web/Models/Annotation/Background.cs index aa770b87..fc0b76a4 100644 --- a/EnvelopeGenerator.Web/Models/Annotation/Background.cs +++ b/EnvelopeGenerator.Web/Models/Annotation/Background.cs @@ -2,6 +2,10 @@ namespace EnvelopeGenerator.Web.Models.Annotation; +/// +/// The Background is an annotation for the PSPDF Kit. However, it has no function. +/// It is only the first annotation as a background for other annotations. +/// public record Background : IAnnotation { [JsonIgnore]