diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-11-09 01:13:27 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-11-09 01:13:27 +0700 |
commit | a8a17fd70fc8df3ca7402323ad5c4f36b25cb806 (patch) | |
tree | 9b276b62885505abbb899d17744b65b912072140 /crypto/src/openpgp/PgpLiteralDataGenerator.cs | |
parent | Primes improvements (diff) | |
download | BouncyCastle.NET-ed25519-a8a17fd70fc8df3ca7402323ad5c4f36b25cb806.tar.xz |
Dispose cleanup
- IDisposable for PemReader, PemWriter, IStreamGenerator
Diffstat (limited to 'crypto/src/openpgp/PgpLiteralDataGenerator.cs')
-rw-r--r-- | crypto/src/openpgp/PgpLiteralDataGenerator.cs | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/crypto/src/openpgp/PgpLiteralDataGenerator.cs b/crypto/src/openpgp/PgpLiteralDataGenerator.cs index f9a9e7cad..fd59c1ebe 100644 --- a/crypto/src/openpgp/PgpLiteralDataGenerator.cs +++ b/crypto/src/openpgp/PgpLiteralDataGenerator.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using System.Text; using Org.BouncyCastle.Utilities; using Org.BouncyCastle.Utilities.Date; @@ -163,18 +162,27 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp return Open(outStr, format, file.Name, file.Length, file.LastWriteTime); } - /// <summary> - /// Close the literal data packet - this is equivalent to calling Close() - /// on the stream returned by the Open() method. - /// </summary> - public void Close() + #region IDisposable + + public void Dispose() { - if (pkOut != null) - { - pkOut.Finish(); - pkOut.Flush(); - pkOut = null; - } - } + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + if (pkOut != null) + { + pkOut.Finish(); + pkOut.Flush(); + pkOut = null; + } + } + } + + #endregion } } |