using MediaBrowser.Model.Serialization;
using Newtonsoft.Json;
using System;
using System.IO;
namespace MediaBrowser.ApiInteraction
{
///
/// Class NewtonsoftJsonSerializer
///
public class NewtonsoftJsonSerializer : IJsonSerializer
{
///
/// Serializes to stream.
///
/// The obj.
/// The stream.
///
/// obj
public void SerializeToStream(object obj, Stream stream)
{
throw new NotImplementedException();
}
///
/// Deserializes from stream.
///
/// The stream.
/// The type.
/// System.Object.
public object DeserializeFromStream(Stream stream, Type type)
{
using (var streamReader = new StreamReader(stream))
{
using (var jsonReader = new JsonTextReader(streamReader))
{
return JsonSerializer.Create(new JsonSerializerSettings()).Deserialize(jsonReader, type);
}
}
}
///
/// Deserializes from stream.
///
///
/// The stream.
/// ``0.
public T DeserializeFromStream(Stream stream)
{
return (T)DeserializeFromStream(stream, typeof(T));
}
///
/// Deserializes from string.
///
///
/// The text.
/// ``0.
///
public T DeserializeFromString(string text)
{
throw new NotImplementedException();
}
///
/// Deserializes from string.
///
/// The json.
/// The type.
/// System.Object.
///
public object DeserializeFromString(string json, Type type)
{
throw new NotImplementedException();
}
///
/// Serializes to string.
///
/// The obj.
/// System.String.
public string SerializeToString(object obj)
{
using (var streamWriter = new StringWriter())
{
using (var jsonWriter = new JsonTextWriter((streamWriter)))
{
JsonSerializer.Create(new JsonSerializerSettings()).Serialize(jsonWriter, obj);
}
return streamWriter.ToString();
}
}
///
/// Serializes to bytes.
///
/// The obj.
/// System.Byte[][].
///
public byte[] SerializeToBytes(object obj)
{
throw new NotImplementedException();
}
///
/// Serializes to file.
///
/// The obj.
/// The file.
///
/// obj
public void SerializeToFile(object obj, string file)
{
throw new NotImplementedException();
}
///
/// Deserializes from file.
///
/// The type.
/// The file.
/// System.Object.
///
public object DeserializeFromFile(Type type, string file)
{
throw new NotImplementedException();
}
///
/// Deserializes from file.
///
///
/// The file.
/// ``0.
///
public T DeserializeFromFile(string file) where T : class
{
throw new NotImplementedException();
}
}
}