From d3ff3f8955dbc036f365e9c149e43a69d4e60b5b Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Tue, 29 Aug 2017 16:03:00 -0400 Subject: [PATCH] Moving util method for caching a type with Newtonsoft JSON --- ICD.Common.Utils/Json/JsonUtils.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ICD.Common.Utils/Json/JsonUtils.cs b/ICD.Common.Utils/Json/JsonUtils.cs index fede785..5c9b937 100644 --- a/ICD.Common.Utils/Json/JsonUtils.cs +++ b/ICD.Common.Utils/Json/JsonUtils.cs @@ -2,6 +2,7 @@ using System.Text; using ICD.Common.Properties; using ICD.Common.Utils.Extensions; +using Newtonsoft.Json; namespace ICD.Common.Utils.Json { @@ -11,6 +12,17 @@ namespace ICD.Common.Utils.Json [PublicAPI] public static class JsonUtils { + /// + /// Forces Newtonsoft to cache the given type for faster subsequent usage. + /// + /// + public static void CacheType() + where T : new() + { + string serialized = JsonConvert.SerializeObject(ReflectionUtils.CreateInstance()); + JsonConvert.DeserializeObject(serialized); + } + /// /// Pretty-prints the JSON document. ///