aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Localization/LocalizationManager.cs
diff options
context:
space:
mode:
authorDavid <daullmer@gmail.com>2020-12-23 13:12:40 +0100
committerDavid <daullmer@gmail.com>2020-12-23 13:14:40 +0100
commit196388d607a856050221d1b55192360dd3ea8be5 (patch)
tree5e56681f7d903db4efc567945c2ac6c9366b95fc /Emby.Server.Implementations/Localization/LocalizationManager.cs
parentbc0976ceac32b5f7e0ef234ec01a0b17477b9086 (diff)
Remove custom Json serializer from Emby.Server.Implementations
Diffstat (limited to 'Emby.Server.Implementations/Localization/LocalizationManager.cs')
-rw-r--r--Emby.Server.Implementations/Localization/LocalizationManager.cs14
1 files changed, 8 insertions, 6 deletions
diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs
index 30aaf3a05..11355872f 100644
--- a/Emby.Server.Implementations/Localization/LocalizationManager.cs
+++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs
@@ -5,7 +5,9 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
+using System.Text.Json;
using System.Threading.Tasks;
+using MediaBrowser.Common.Json;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Globalization;
@@ -24,7 +26,6 @@ namespace Emby.Server.Implementations.Localization
private static readonly string[] _unratedValues = { "n/a", "unrated", "not rated" };
private readonly IServerConfigurationManager _configurationManager;
- private readonly IJsonSerializer _jsonSerializer;
private readonly ILogger<LocalizationManager> _logger;
private readonly Dictionary<string, Dictionary<string, ParentalRating>> _allParentalRatings =
@@ -43,11 +44,9 @@ namespace Emby.Server.Implementations.Localization
/// <param name="logger">The logger.</param>
public LocalizationManager(
IServerConfigurationManager configurationManager,
- IJsonSerializer jsonSerializer,
ILogger<LocalizationManager> logger)
{
_configurationManager = configurationManager;
- _jsonSerializer = jsonSerializer;
_logger = logger;
}
@@ -179,8 +178,11 @@ namespace Emby.Server.Implementations.Localization
/// <inheritdoc />
public IEnumerable<CountryInfo> GetCountries()
- => _jsonSerializer.DeserializeFromStream<IEnumerable<CountryInfo>>(
- _assembly.GetManifestResourceStream("Emby.Server.Implementations.Localization.countries.json"));
+ {
+ StreamReader reader = new StreamReader(_assembly.GetManifestResourceStream("Emby.Server.Implementations.Localization.countries.json"));
+
+ return JsonSerializer.Deserialize<IEnumerable<CountryInfo>>(reader.ReadToEnd(), JsonDefaults.GetOptions());
+ }
/// <inheritdoc />
public IEnumerable<ParentalRating> GetParentalRatings()
@@ -344,7 +346,7 @@ namespace Emby.Server.Implementations.Localization
// If a Culture doesn't have a translation the stream will be null and it defaults to en-us further up the chain
if (stream != null)
{
- var dict = await _jsonSerializer.DeserializeFromStreamAsync<Dictionary<string, string>>(stream).ConfigureAwait(false);
+ var dict = await JsonSerializer.DeserializeAsync<Dictionary<string, string>>(stream, JsonDefaults.GetOptions()).ConfigureAwait(false);
foreach (var key in dict.Keys)
{