mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-14 04:05:04 +00:00
40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
#if NETFRAMEWORK
|
|
extern alias RealNewtonsoft;
|
|
using RealNewtonsoft.Newtonsoft.Json;
|
|
#else
|
|
using Newtonsoft.Json;
|
|
#endif
|
|
using System;
|
|
using ICD.Common.Utils.Extensions;
|
|
|
|
namespace ICD.Common.Utils.Json
|
|
{
|
|
public sealed class MinimalTypeConverter : AbstractGenericJsonConverter<Type>
|
|
{
|
|
/// <summary>
|
|
/// Writes the JSON representation of the object.
|
|
/// </summary>
|
|
/// <param name="writer">The <see cref="T:Newtonsoft.Json.JsonWriter"/> to write to.</param>
|
|
/// <param name="value">The value.</param>
|
|
/// <param name="serializer">The calling serializer.</param>
|
|
public override void WriteJson(JsonWriter writer, Type value, JsonSerializer serializer)
|
|
{
|
|
writer.WriteType(value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Reads the JSON representation of the object.
|
|
/// </summary>
|
|
/// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader"/> to read from.</param>
|
|
/// <param name="existingValue">The existing value of object being read.</param>
|
|
/// <param name="serializer">The calling serializer.</param>
|
|
/// <returns>
|
|
/// The object value.
|
|
/// </returns>
|
|
public override Type ReadJson(JsonReader reader, Type existingValue, JsonSerializer serializer)
|
|
{
|
|
return reader.GetValueAsType();
|
|
}
|
|
}
|
|
}
|