mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-12 12:07:05 +00:00
Fixed IcdTextWriter's IDisposable implementation
This commit is contained in:
parent
01ddf830d6
commit
ff66d635ae
1 changed files with 19 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue