mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 13:15:07 +00:00
Fixed IcdTextWriter's IDisposable implementation
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
#if SIMPLSHARP
|
#if SIMPLSHARP
|
||||||
using Crestron.SimplSharp.CrestronIO;
|
using Crestron.SimplSharp.CrestronIO;
|
||||||
|
using GC = Crestron.SimplSharp.CrestronEnvironment.GC;
|
||||||
#else
|
#else
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using GC = System.GC;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace ICD.Common.Utils.IO
|
namespace ICD.Common.Utils.IO
|
||||||
@@ -13,6 +15,8 @@ namespace ICD.Common.Utils.IO
|
|||||||
|
|
||||||
public TextWriter WrappedTextWriter { get { return m_TextWriter; } }
|
public TextWriter WrappedTextWriter { get { return m_TextWriter; } }
|
||||||
|
|
||||||
|
private bool disposed = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -27,12 +31,25 @@ namespace ICD.Common.Utils.IO
|
|||||||
|
|
||||||
~IcdTextWriter()
|
~IcdTextWriter()
|
||||||
{
|
{
|
||||||
Dispose();
|
Dispose(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
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