jellyfin-server/MediaBrowser.Model/Serialization/IJsonSerializer.cs
Erwin de Haan ec1f5dc317 Mayor code cleanup
Add Argument*Exceptions now use proper nameof operators.

Added exception messages to quite a few Argument*Exceptions.

Fixed rethorwing to be proper syntax.

Added a ton of null checkes. (This is only a start, there are about 500 places that need proper null handling)

Added some TODOs to log certain exceptions.

Fix sln again.

Fixed all AssemblyInfo's and added proper copyright (where I could find them)

We live in *current year*.

Fixed the use of braces.

Fixed a ton of properties, and made a fair amount of functions static that should be and can be static.

Made more Methods that should be static static.

You can now use static to find bad functions!

Removed unused variable. And added one more proper XML comment.
2019-01-10 20:38:53 +01:00

92 lines
3.2 KiB
C#

using System;
using System.IO;
using System.Threading.Tasks;
namespace MediaBrowser.Model.Serialization
{
public interface IJsonSerializer
{
/// <summary>
/// Serializes to stream.
/// </summary>
/// <param name="obj">The obj.</param>
/// <param name="stream">The stream.</param>
/// <exception cref="ArgumentNullException">obj</exception>
void SerializeToStream(object obj, Stream stream);
/// <summary>
/// Serializes to file.
/// </summary>
/// <param name="obj">The obj.</param>
/// <param name="file">The file.</param>
/// <exception cref="ArgumentNullException">obj</exception>
void SerializeToFile(object obj, string file);
/// <summary>
/// Deserializes from file.
/// </summary>
/// <param name="type">The type.</param>
/// <param name="file">The file.</param>
/// <returns>System.Object.</returns>
/// <exception cref="ArgumentNullException">type</exception>
object DeserializeFromFile(Type type, string file);
/// <summary>
/// Deserializes from file.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="file">The file.</param>
/// <returns>``0.</returns>
/// <exception cref="ArgumentNullException">file</exception>
T DeserializeFromFile<T>(string file)
where T : class;
/// <summary>
/// Deserializes from stream.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="stream">The stream.</param>
/// <returns>``0.</returns>
/// <exception cref="ArgumentNullException">stream</exception>
T DeserializeFromStream<T>(Stream stream);
/// <summary>
/// Deserializes from string.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="text">The text.</param>
/// <returns>``0.</returns>
/// <exception cref="ArgumentNullException">text</exception>
T DeserializeFromString<T>(string text);
/// <summary>
/// Deserializes from stream.
/// </summary>
/// <param name="stream">The stream.</param>
/// <param name="type">The type.</param>
/// <returns>System.Object.</returns>
/// <exception cref="ArgumentNullException">stream</exception>
object DeserializeFromStream(Stream stream, Type type);
/// <summary>
/// Deserializes from string.
/// </summary>
/// <param name="json">The json.</param>
/// <param name="type">The type.</param>
/// <returns>System.Object.</returns>
/// <exception cref="ArgumentNullException">json</exception>
object DeserializeFromString(string json, Type type);
/// <summary>
/// Serializes to string.
/// </summary>
/// <param name="obj">The obj.</param>
/// <returns>System.String.</returns>
/// <exception cref="ArgumentNullException">obj</exception>
string SerializeToString(object obj);
Task<object> DeserializeFromStreamAsync(Stream stream, Type type);
Task<T> DeserializeFromStreamAsync<T>(Stream stream);
}
}