mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-12 11:15:12 +00:00
Fixed IcdTextWriter's IDisposable implementation
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user