Fixed IcdTextWriter's IDisposable implementation

This commit is contained in:
jeffery.thompson
2017-07-18 10:01:26 -04:00
parent 01ddf830d6
commit ff66d635ae

View File

@@ -1,8 +1,10 @@
using System;
#if SIMPLSHARP
using Crestron.SimplSharp.CrestronIO;
using GC = Crestron.SimplSharp.CrestronEnvironment.GC;
#else
using System.IO;
using GC = System.GC;
#endif
namespace ICD.Common.Utils.IO
@@ -13,6 +15,8 @@ namespace ICD.Common.Utils.IO
public TextWriter WrappedTextWriter { get { return m_TextWriter; } }
private bool disposed = false;
/// <summary>
/// Constructor.
/// </summary>
@@ -27,12 +31,25 @@ namespace ICD.Common.Utils.IO
~IcdTextWriter()
{
Dispose();
Dispose(false);
}
public void Dispose()
{
m_TextWriter.Dispose();
Dispose(true);
GC.SuppressFinalize(this);
}
protected void Dispose(bool disposing)
{
if (disposed)
return;
if (disposing)
{
m_TextWriter.Dispose();
}
disposed = true;
}
}
}