refactor(AnnotationHandler): update to use System.Text.Json.JsonSerializer
This commit is contained in:
parent
4eb6d87770
commit
e990a466aa
@ -1,8 +1,7 @@
|
|||||||
using EnvelopeGenerator.Application.Common.Notifications.DocSigned;
|
using EnvelopeGenerator.Application.DocStatus.Commands;
|
||||||
using EnvelopeGenerator.Application.DocStatus.Commands;
|
|
||||||
using EnvelopeGenerator.Domain.Constants;
|
using EnvelopeGenerator.Domain.Constants;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Newtonsoft.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Common.Notifications.DocSigned.Handlers;
|
namespace EnvelopeGenerator.Application.Common.Notifications.DocSigned.Handlers;
|
||||||
|
|
||||||
@ -34,7 +33,7 @@ public class AnnotationHandler : INotificationHandler<DocSignedNotification>
|
|||||||
{
|
{
|
||||||
Envelope = new() { Id = notification.EnvelopeId },
|
Envelope = new() { Id = notification.EnvelopeId },
|
||||||
Receiver = new() { Id = notification.ReceiverId},
|
Receiver = new() { Id = notification.ReceiverId},
|
||||||
Value = JsonConvert.SerializeObject(notification.Annotations, Format.Json.ForAnnotations)
|
Value = JsonSerializer.Serialize(notification.Annotations, Format.Json.ForAnnotations)
|
||||||
}, cancel);
|
}, cancel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,4 @@
|
|||||||
using EnvelopeGenerator.Application.Common.Notifications.DocSigned;
|
using EnvelopeGenerator.Application.Histories.Commands;
|
||||||
using EnvelopeGenerator.Application.Histories.Commands;
|
|
||||||
using EnvelopeGenerator.Domain.Constants;
|
using EnvelopeGenerator.Domain.Constants;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@ -39,7 +38,6 @@ public class HistoryHandler : INotificationHandler<DocSignedNotification>
|
|||||||
EnvelopeId = notification.EnvelopeId,
|
EnvelopeId = notification.EnvelopeId,
|
||||||
UserReference = notification.Receiver.EmailAddress,
|
UserReference = notification.Receiver.EmailAddress,
|
||||||
Status = EnvelopeStatus.DocumentSigned,
|
Status = EnvelopeStatus.DocumentSigned,
|
||||||
Comment = JsonConvert.SerializeObject(notification.Annotations, Format.Json.ForAnnotations)
|
|
||||||
}, cancel);
|
}, cancel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,9 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Serialization;
|
using Newtonsoft.Json.Serialization;
|
||||||
|
#if NET
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Domain.Constants
|
namespace EnvelopeGenerator.Domain.Constants
|
||||||
{
|
{
|
||||||
@ -8,18 +12,22 @@ namespace EnvelopeGenerator.Domain.Constants
|
|||||||
#region Json Serializer Settings
|
#region Json Serializer Settings
|
||||||
public static class Json
|
public static class Json
|
||||||
{
|
{
|
||||||
|
//TODO: update to use System.Text.Json
|
||||||
public static readonly JsonSerializerSettings ForDiagnostics = new JsonSerializerSettings()
|
public static readonly JsonSerializerSettings ForDiagnostics = new JsonSerializerSettings()
|
||||||
{
|
{
|
||||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
||||||
Formatting = Formatting.Indented,
|
Formatting = Formatting.Indented,
|
||||||
NullValueHandling = NullValueHandling.Include
|
NullValueHandling = NullValueHandling.Include
|
||||||
};
|
};
|
||||||
public static readonly JsonSerializerSettings ForAnnotations = new JsonSerializerSettings()
|
|
||||||
|
#if NET
|
||||||
|
public static readonly JsonSerializerOptions ForAnnotations = new()
|
||||||
{
|
{
|
||||||
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||||
Formatting = Formatting.None,
|
WriteIndented = false,
|
||||||
NullValueHandling = NullValueHandling.Ignore
|
DefaultIgnoreCondition = JsonIgnoreCondition.Never,
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using DigitalData.Core.Abstraction.Application.DTO;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using DigitalData.Core.Exceptions;
|
||||||
|
using EnvelopeGenerator.Application.Common.Extensions;
|
||||||
|
using EnvelopeGenerator.Application.Common.Notifications.DocSigned;
|
||||||
|
using EnvelopeGenerator.Application.EnvelopeReceivers.Queries;
|
||||||
using EnvelopeGenerator.Application.Interfaces.Services;
|
using EnvelopeGenerator.Application.Interfaces.Services;
|
||||||
using EnvelopeGenerator.Domain.Constants;
|
using EnvelopeGenerator.Domain.Constants;
|
||||||
using DigitalData.Core.Abstraction.Application.DTO;
|
|
||||||
using EnvelopeGenerator.Web.Extensions;
|
using EnvelopeGenerator.Web.Extensions;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System.Dynamic;
|
using System.Dynamic;
|
||||||
using EnvelopeGenerator.Application.EnvelopeReceivers.Queries;
|
|
||||||
using DigitalData.Core.Exceptions;
|
|
||||||
using EnvelopeGenerator.Application.Common.Notifications.DocSigned;
|
|
||||||
using EnvelopeGenerator.Application.Common.Extensions;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Web.Controllers;
|
namespace EnvelopeGenerator.Web.Controllers;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user