mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 21:24:58 +00:00
refactor: Removing unused code
This commit is contained in:
@@ -22,28 +22,6 @@ namespace ICD.Common.Utils.Json
|
|||||||
private const string MESSAGE_NAME_PROPERTY = "m";
|
private const string MESSAGE_NAME_PROPERTY = "m";
|
||||||
private const string MESSAGE_DATA_PROPERTY = "d";
|
private const string MESSAGE_DATA_PROPERTY = "d";
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Forces Newtonsoft to cache the given type for faster subsequent usage.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
public static void CacheType<T>()
|
|
||||||
where T : new()
|
|
||||||
{
|
|
||||||
CacheType(typeof(T));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Forces Newtonsoft to cache the given type for faster subsequent usage.
|
|
||||||
/// </summary>
|
|
||||||
public static void CacheType(Type type)
|
|
||||||
{
|
|
||||||
if (type == null)
|
|
||||||
throw new ArgumentNullException("type");
|
|
||||||
|
|
||||||
string serialized = JsonConvert.SerializeObject(ReflectionUtils.CreateInstance(type));
|
|
||||||
JsonConvert.DeserializeObject(serialized, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the token as a DateTime value.
|
/// Gets the token as a DateTime value.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -87,31 +65,6 @@ namespace ICD.Common.Utils.Json
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Pretty-prints the JSON document.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="json"></param>
|
|
||||||
[PublicAPI]
|
|
||||||
public static void Print(string json)
|
|
||||||
{
|
|
||||||
if (json == null)
|
|
||||||
throw new ArgumentNullException("json");
|
|
||||||
|
|
||||||
string formatted = Format(json);
|
|
||||||
IcdConsole.PrintLine(formatted);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Serializes the given item and pretty-prints to JSON.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value"></param>
|
|
||||||
[PublicAPI]
|
|
||||||
public static void Print(object value)
|
|
||||||
{
|
|
||||||
string formatted = Format(value);
|
|
||||||
IcdConsole.PrintLine(formatted);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Serializes the given item and formats the JSON into a human-readable form.
|
/// Serializes the given item and formats the JSON into a human-readable form.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -317,44 +270,5 @@ namespace ICD.Common.Utils.Json
|
|||||||
},
|
},
|
||||||
json);
|
json);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Deserializes the given token based on the known type.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="type"></param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static object Deserialize(Type type, JToken token)
|
|
||||||
{
|
|
||||||
if (type == null)
|
|
||||||
throw new ArgumentNullException("type");
|
|
||||||
|
|
||||||
if (token == null)
|
|
||||||
throw new ArgumentNullException("token");
|
|
||||||
|
|
||||||
return Deserialize(type, token, new JsonSerializer());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Deserializes the given token based on the known type.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="type"></param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <param name="serializer"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static object Deserialize(Type type, JToken token, JsonSerializer serializer)
|
|
||||||
{
|
|
||||||
if (type == null)
|
|
||||||
throw new ArgumentNullException("type");
|
|
||||||
|
|
||||||
if (token == null)
|
|
||||||
throw new ArgumentNullException("token");
|
|
||||||
|
|
||||||
if (serializer == null)
|
|
||||||
throw new ArgumentNullException("serializer");
|
|
||||||
|
|
||||||
using (JTokenReader jsonReader = new JTokenReader(token))
|
|
||||||
return serializer.Deserialize(jsonReader, type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user