diff options
Diffstat (limited to 'crypto/src/util/io/pem/PemReader.cs')
-rw-r--r-- | crypto/src/util/io/pem/PemReader.cs | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/crypto/src/util/io/pem/PemReader.cs b/crypto/src/util/io/pem/PemReader.cs index cd19e95b8..77b457338 100644 --- a/crypto/src/util/io/pem/PemReader.cs +++ b/crypto/src/util/io/pem/PemReader.cs @@ -6,8 +6,8 @@ using Org.BouncyCastle.Utilities.Encoders; namespace Org.BouncyCastle.Utilities.IO.Pem { - public class PemReader + : IDisposable { private readonly TextReader reader; private readonly MemoryStream buffer; @@ -17,17 +17,30 @@ namespace Org.BouncyCastle.Utilities.IO.Pem public PemReader(TextReader reader) { - if (reader == null) - throw new ArgumentNullException("reader"); + this.reader = reader ?? throw new ArgumentNullException(nameof(reader)); + this.buffer = new MemoryStream(); + this.textBuffer = new StreamWriter(buffer); + } + #region IDisposable - buffer = new MemoryStream(); - textBuffer = new StreamWriter(buffer); + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - this.reader = reader; - } + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + reader.Dispose(); + } + } + + #endregion - public TextReader Reader + public TextReader Reader { get { return reader; } } |