diff options
author | HombreLaser <sebastian-440@live.com> | 2022-11-22 16:46:29 -0600 |
---|---|---|
committer | HombreLaser <sebastian-440@live.com> | 2022-11-22 16:46:29 -0600 |
commit | ea20e100d4afe4429ab4c24926bffc0a8f9b9b70 (patch) | |
tree | 413ba66d90d4bc0ec51e20abe73fc3b2d08f50d5 /JPIF.cs | |
parent | b3deb8c5d92dd616042ea9e265c197abe02f995c (diff) |
Añadido configuración de newtonsoft json
Diffstat (limited to 'JPIF.cs')
-rw-r--r-- | JPIF.cs | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -0,0 +1,22 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Formatters; +using Microsoft.Extensions.Options; + +namespace BackendPIA { + public static class JPIF { + public static NewtonsoftJsonPatchInputFormatter GetJsonPatchInputFormatter() { + var builder = new ServiceCollection() + .AddLogging() + .AddMvc() + .AddNewtonsoftJson() + .Services.BuildServiceProvider(); + + return builder + .GetRequiredService<IOptions<MvcOptions>>() + .Value + .InputFormatters + .OfType<NewtonsoftJsonPatchInputFormatter>() + .First(); + } + } +}
\ No newline at end of file |