aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Serialization/JsonSerializer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Serialization/JsonSerializer.cs')
-rw-r--r--Emby.Server.Implementations/Serialization/JsonSerializer.cs34
1 files changed, 16 insertions, 18 deletions
diff --git a/Emby.Server.Implementations/Serialization/JsonSerializer.cs b/Emby.Server.Implementations/Serialization/JsonSerializer.cs
index d4b6b2f43..53ef5d60c 100644
--- a/Emby.Server.Implementations/Serialization/JsonSerializer.cs
+++ b/Emby.Server.Implementations/Serialization/JsonSerializer.cs
@@ -1,9 +1,9 @@
using System;
using System.IO;
+using System.Threading.Tasks;
using MediaBrowser.Model.IO;
-using Microsoft.Extensions.Logging;
using MediaBrowser.Model.Serialization;
-using System.Threading.Tasks;
+using Microsoft.Extensions.Logging;
namespace Emby.Common.Implementations.Serialization
{
@@ -13,12 +13,11 @@ namespace Emby.Common.Implementations.Serialization
public class JsonSerializer : IJsonSerializer
{
private readonly IFileSystem _fileSystem;
- private readonly ILogger _logger;
- public JsonSerializer(IFileSystem fileSystem, ILogger logger)
+ public JsonSerializer(
+ IFileSystem fileSystem)
{
_fileSystem = fileSystem;
- _logger = logger;
Configure();
}
@@ -27,7 +26,7 @@ namespace Emby.Common.Implementations.Serialization
/// </summary>
/// <param name="obj">The obj.</param>
/// <param name="stream">The stream.</param>
- /// <exception cref="System.ArgumentNullException">obj</exception>
+ /// <exception cref="ArgumentNullException">obj</exception>
public void SerializeToStream(object obj, Stream stream)
{
if (obj == null)
@@ -48,7 +47,7 @@ namespace Emby.Common.Implementations.Serialization
/// </summary>
/// <param name="obj">The obj.</param>
/// <param name="file">The file.</param>
- /// <exception cref="System.ArgumentNullException">obj</exception>
+ /// <exception cref="ArgumentNullException">obj</exception>
public void SerializeToFile(object obj, string file)
{
if (obj == null)
@@ -61,7 +60,7 @@ namespace Emby.Common.Implementations.Serialization
throw new ArgumentNullException(nameof(file));
}
- using (Stream stream = _fileSystem.GetFileStream(file, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
+ using (var stream = _fileSystem.GetFileStream(file, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
{
SerializeToStream(obj, stream);
}
@@ -69,7 +68,6 @@ namespace Emby.Common.Implementations.Serialization
private static Stream OpenFile(string path)
{
- //_logger.LogDebug("Deserializing file {0}", path);
return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 131072);
}
@@ -79,7 +77,7 @@ namespace Emby.Common.Implementations.Serialization
/// <param name="type">The type.</param>
/// <param name="file">The file.</param>
/// <returns>System.Object.</returns>
- /// <exception cref="System.ArgumentNullException">type</exception>
+ /// <exception cref="ArgumentNullException">type</exception>
public object DeserializeFromFile(Type type, string file)
{
if (type == null)
@@ -92,7 +90,7 @@ namespace Emby.Common.Implementations.Serialization
throw new ArgumentNullException(nameof(file));
}
- using (Stream stream = OpenFile(file))
+ using (var stream = OpenFile(file))
{
return DeserializeFromStream(stream, type);
}
@@ -104,7 +102,7 @@ namespace Emby.Common.Implementations.Serialization
/// <typeparam name="T"></typeparam>
/// <param name="file">The file.</param>
/// <returns>``0.</returns>
- /// <exception cref="System.ArgumentNullException">file</exception>
+ /// <exception cref="ArgumentNullException">file</exception>
public T DeserializeFromFile<T>(string file)
where T : class
{
@@ -113,7 +111,7 @@ namespace Emby.Common.Implementations.Serialization
throw new ArgumentNullException(nameof(file));
}
- using (Stream stream = OpenFile(file))
+ using (var stream = OpenFile(file))
{
return DeserializeFromStream<T>(stream);
}
@@ -125,7 +123,7 @@ namespace Emby.Common.Implementations.Serialization
/// <typeparam name="T"></typeparam>
/// <param name="stream">The stream.</param>
/// <returns>``0.</returns>
- /// <exception cref="System.ArgumentNullException">stream</exception>
+ /// <exception cref="ArgumentNullException">stream</exception>
public T DeserializeFromStream<T>(Stream stream)
{
if (stream == null)
@@ -153,7 +151,7 @@ namespace Emby.Common.Implementations.Serialization
/// <typeparam name="T"></typeparam>
/// <param name="text">The text.</param>
/// <returns>``0.</returns>
- /// <exception cref="System.ArgumentNullException">text</exception>
+ /// <exception cref="ArgumentNullException">text</exception>
public T DeserializeFromString<T>(string text)
{
if (string.IsNullOrEmpty(text))
@@ -170,7 +168,7 @@ namespace Emby.Common.Implementations.Serialization
/// <param name="stream">The stream.</param>
/// <param name="type">The type.</param>
/// <returns>System.Object.</returns>
- /// <exception cref="System.ArgumentNullException">stream</exception>
+ /// <exception cref="ArgumentNullException">stream</exception>
public object DeserializeFromStream(Stream stream, Type type)
{
if (stream == null)
@@ -236,7 +234,7 @@ namespace Emby.Common.Implementations.Serialization
/// <param name="json">The json.</param>
/// <param name="type">The type.</param>
/// <returns>System.Object.</returns>
- /// <exception cref="System.ArgumentNullException">json</exception>
+ /// <exception cref="ArgumentNullException">json</exception>
public object DeserializeFromString(string json, Type type)
{
if (string.IsNullOrEmpty(json))
@@ -257,7 +255,7 @@ namespace Emby.Common.Implementations.Serialization
/// </summary>
/// <param name="obj">The obj.</param>
/// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentNullException">obj</exception>
+ /// <exception cref="ArgumentNullException">obj</exception>
public string SerializeToString(object obj)
{
if (obj == null)