Renamed namespaces and related identifiers from EnvelopeGenerator.WebUI to EnvelopeGenerator.Server across the project. This change affects data models, services, controllers, and configuration files to ensure consistency with the new architecture. Updated @using directives in Razor components and other files to reflect the new namespace structure. Adjusted project references in EnvelopeGenerator.Server.csproj to point to the new EnvelopeGenerator.Server.Client project. Modified middleware and logging configurations to use the new EnvelopeGenerator.Server namespace, including changes in Program.cs and appsettings.json. Updated resource and file references to use the new EnvelopeGenerator.Server path, ensuring correct resource loading. Adjusted configuration options in Program.cs to use the new namespace for options classes, such as ApiOptions and PdfViewerOptions. Updated authentication scheme names and related constants to align with the new namespace structure. Revised comments and documentation to reflect the new namespace, ensuring clarity and consistency in the codebase.
81 lines
2.7 KiB
C#
81 lines
2.7 KiB
C#
using EnvelopeGenerator.Server.Models.PsPdfKitAnnotation;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace EnvelopeGenerator.Server.Models.PsPdfKitAnnotation;
|
|
|
|
public class AnnotationParams
|
|
{
|
|
public AnnotationParams()
|
|
{
|
|
_AnnotationJSObjectInitor = new(CreateAnnotationJSObject);
|
|
}
|
|
|
|
public Background? Background { get; init; }
|
|
|
|
#region Annotation
|
|
[JsonIgnore]
|
|
public Annotation? DefaultAnnotation { get; init; }
|
|
|
|
private readonly List<Annotation> _annots = new List<Annotation>();
|
|
|
|
public bool TryGet(string name, out Annotation annotation)
|
|
{
|
|
#pragma warning disable CS8601 // Possible null reference assignment.
|
|
annotation = _annots.FirstOrDefault(a => a.Name == name);
|
|
#pragma warning restore CS8601 // Possible null reference assignment.
|
|
return annotation is not null;
|
|
}
|
|
|
|
public required IEnumerable<Annotation> Annotations
|
|
{
|
|
get => _annots;
|
|
init
|
|
{
|
|
_annots = value.ToList();
|
|
|
|
if (DefaultAnnotation is not null)
|
|
foreach (var annot in _annots)
|
|
annot.Default = DefaultAnnotation;
|
|
|
|
for (int i = 0; i < _annots.Count; i++)
|
|
{
|
|
#region set bound annotations
|
|
// horizontal
|
|
if (_annots[i].HorBoundAnnotName is string horBoundAnnotName)
|
|
if (TryGet(horBoundAnnotName, out var horBoundAnnot))
|
|
_annots[i].HorBoundAnnot = horBoundAnnot;
|
|
else
|
|
throw new InvalidOperationException($"{horBoundAnnotName} added as bound anotation. However, it is not defined.");
|
|
|
|
// vertical
|
|
if (_annots[i].VerBoundAnnotName is string verBoundAnnotName)
|
|
if (TryGet(verBoundAnnotName, out var verBoundAnnot))
|
|
_annots[i].VerBoundAnnot = verBoundAnnot;
|
|
else
|
|
throw new InvalidOperationException($"{verBoundAnnotName} added as bound anotation. However, it is not defined.");
|
|
#endregion
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region AnnotationJSObject
|
|
private Dictionary<string, IAnnotation> CreateAnnotationJSObject()
|
|
{
|
|
var dict = _annots.ToDictionary(a => a.Name.ToLower(), a => a as IAnnotation);
|
|
|
|
if (Background is not null)
|
|
{
|
|
Background.Locate(_annots);
|
|
dict.Add(Background.Name.ToLower(), Background);
|
|
}
|
|
|
|
return dict;
|
|
}
|
|
|
|
private readonly Lazy<Dictionary<string, IAnnotation>> _AnnotationJSObjectInitor;
|
|
|
|
public Dictionary<string, IAnnotation> AnnotationJSObject => _AnnotationJSObjectInitor.Value;
|
|
#endregion
|
|
}
|