diff --git a/ICD.Common.Utils/IO/IcdTextReader.cs b/ICD.Common.Utils/IO/IcdTextReader.cs index 6c2285f..e5c9801 100644 --- a/ICD.Common.Utils/IO/IcdTextReader.cs +++ b/ICD.Common.Utils/IO/IcdTextReader.cs @@ -1,13 +1,13 @@ -#if SIMPLSHARP +using System; +#if SIMPLSHARP using Crestron.SimplSharp.CrestronIO; - #else using System.IO; #endif namespace ICD.Common.Utils.IO { - public class IcdTextReader + public class IcdTextReader : IDisposable { private readonly TextReader m_TextReader; @@ -17,5 +17,10 @@ namespace ICD.Common.Utils.IO { m_TextReader = textReader; } + + public void Dispose() + { + m_TextReader.Dispose(); + } } } diff --git a/ICD.Common.Utils/Json/JsonUtils.cs b/ICD.Common.Utils/Json/JsonUtils.cs index 6449cd7..56270bb 100644 --- a/ICD.Common.Utils/Json/JsonUtils.cs +++ b/ICD.Common.Utils/Json/JsonUtils.cs @@ -205,8 +205,11 @@ namespace ICD.Common.Utils.Json StringBuilder builder = new StringBuilder(); - using (JsonTextWriter writer = new JsonTextWriter(new IcdStringWriter(builder).WrappedStringWriter)) - serializeMethod(writer); + using (IcdStringWriter stringWriter = new IcdStringWriter(builder)) + { + using (JsonTextWriter writer = new JsonTextWriter(stringWriter.WrappedStringWriter)) + serializeMethod(writer); + } return builder.ToString(); } @@ -224,8 +227,11 @@ namespace ICD.Common.Utils.Json if (deserializeMethod == null) throw new ArgumentNullException("deserializeMethod"); - using (JsonTextReader reader = new JsonTextReader(new IcdStringReader(json).WrappedStringReader)) - return deserializeMethod(reader); + using (IcdStringReader stringReader = new IcdStringReader(json)) + { + using (JsonTextReader reader = new JsonTextReader(stringReader.WrappedStringReader)) + return deserializeMethod(reader); + } } ///