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() public AnnotationParams()
{ {
_AnnotationJSObjectInitor = new(() => _annots.ToDictionary(a => a.Name.ToLower(), a => a)); _AnnotationJSObjectInitor = new(CreateAnnotationJSObject);
} }
public Background? Background { get; init; } public Background? Background { get; init; }
#region Annotation
[JsonIgnore] [JsonIgnore]
public Annotation? DefaultAnnotation { get; init; } 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
} }

View File

@ -2,6 +2,10 @@
namespace EnvelopeGenerator.Web.Models.Annotation; namespace EnvelopeGenerator.Web.Models.Annotation;
/// <summary>
/// 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.
/// </summary>
public record Background : IAnnotation public record Background : IAnnotation
{ {
[JsonIgnore] [JsonIgnore]