Move field to the controller
This commit is contained in:
parent
9f567e6471
commit
c6a0306a34
|
@ -23,6 +23,8 @@ namespace Jellyfin.Api.Controllers
|
|||
private readonly IServerConfigurationManager _configurationManager;
|
||||
private readonly IMediaEncoder _mediaEncoder;
|
||||
|
||||
private readonly JsonSerializerOptions _serializerOptions = JsonDefaults.GetOptions();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ConfigurationController"/> class.
|
||||
/// </summary>
|
||||
|
@ -88,7 +90,7 @@ namespace Jellyfin.Api.Controllers
|
|||
public async Task<ActionResult> UpdateNamedConfiguration([FromRoute] string? key)
|
||||
{
|
||||
var configurationType = _configurationManager.GetConfigurationType(key);
|
||||
var configuration = await JsonSerializer.DeserializeAsync(Request.Body, configurationType, JsonDefaults.GetOptions()).ConfigureAwait(false);
|
||||
var configuration = await JsonSerializer.DeserializeAsync(Request.Body, configurationType, _serializerOptions).ConfigureAwait(false);
|
||||
_configurationManager.SaveConfiguration(key, configuration);
|
||||
return NoContent();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -27,6 +26,8 @@ namespace Jellyfin.Api.Controllers
|
|||
private readonly IApplicationHost _appHost;
|
||||
private readonly IInstallationManager _installationManager;
|
||||
|
||||
private readonly JsonSerializerOptions _serializerOptions = JsonDefaults.GetOptions();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PluginsController"/> class.
|
||||
/// </summary>
|
||||
|
@ -119,7 +120,7 @@ namespace Jellyfin.Api.Controllers
|
|||
return NotFound();
|
||||
}
|
||||
|
||||
var configuration = (BasePluginConfiguration)await JsonSerializer.DeserializeAsync(Request.Body, plugin.ConfigurationType, JsonDefaults.GetOptions())
|
||||
var configuration = (BasePluginConfiguration)await JsonSerializer.DeserializeAsync(Request.Body, plugin.ConfigurationType, _serializerOptions)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
plugin.UpdateConfiguration(configuration);
|
||||
|
|
|
@ -9,8 +9,6 @@ namespace MediaBrowser.Common.Json
|
|||
/// </summary>
|
||||
public static class JsonDefaults
|
||||
{
|
||||
private static JsonSerializerOptions _defaultOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default <see cref="JsonSerializerOptions" /> options.
|
||||
/// </summary>
|
||||
|
@ -22,8 +20,6 @@ namespace MediaBrowser.Common.Json
|
|||
/// </remarks>
|
||||
/// <returns>The default <see cref="JsonSerializerOptions" /> options.</returns>
|
||||
public static JsonSerializerOptions GetOptions()
|
||||
{
|
||||
if (_defaultOptions == null)
|
||||
{
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
|
@ -38,11 +34,7 @@ namespace MediaBrowser.Common.Json
|
|||
options.Converters.Add(new JsonInt64Converter());
|
||||
options.Converters.Add(new JsonDoubleConverter());
|
||||
|
||||
_defaultOptions = options;
|
||||
return _defaultOptions;
|
||||
}
|
||||
|
||||
return _defaultOptions;
|
||||
return options;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue
Block a user