diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-11-04 19:28:43 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-11-04 19:28:43 +0700 |
commit | f56fc16973d66bd9461f247e50738e55bd54de7e (patch) | |
tree | 8e84c9bd2cfc2d554b99c8045ec46de7313410fc /crypto/src/bcpg/ArmoredOutputStream.cs | |
parent | Port updated revocation test from Java (diff) | |
download | BouncyCastle.NET-ed25519-f56fc16973d66bd9461f247e50738e55bd54de7e.tar.xz |
Replace Close with Dispose for PORTABLE
Diffstat (limited to 'crypto/src/bcpg/ArmoredOutputStream.cs')
-rw-r--r-- | crypto/src/bcpg/ArmoredOutputStream.cs | 67 |
1 files changed, 45 insertions, 22 deletions
diff --git a/crypto/src/bcpg/ArmoredOutputStream.cs b/crypto/src/bcpg/ArmoredOutputStream.cs index 253c5d1fe..0f0d6896c 100644 --- a/crypto/src/bcpg/ArmoredOutputStream.cs +++ b/crypto/src/bcpg/ArmoredOutputStream.cs @@ -283,37 +283,60 @@ namespace Org.BouncyCastle.Bcpg * <b>Note</b>: Close() does not close the underlying stream. So it is possible to write * multiple objects using armoring to a single stream. */ - public override void Close() +#if PORTABLE + protected override void Disposing(bool disposing) { - if (type != null) + if (disposing) { - if (bufPtr > 0) - { - Encode(outStream, buf, bufPtr); - } + if (type == null) + return; - DoWrite(nl + '='); + DoClose(); - int crcV = crc.Value; - - buf[0] = ((crcV >> 16) & 0xff); - buf[1] = ((crcV >> 8) & 0xff); - buf[2] = (crcV & 0xff); + type = null; + start = true; + } + base.Dispose(disposing); + } +#else + public override void Close() + { + if (type == null) + return; - Encode(outStream, buf, 3); + DoClose(); - DoWrite(nl); - DoWrite(footerStart); - DoWrite(type); - DoWrite(footerTail); - DoWrite(nl); + type = null; + start = true; - outStream.Flush(); + base.Close(); + } +#endif - type = null; - start = true; - base.Close(); + private void DoClose() + { + if (bufPtr > 0) + { + Encode(outStream, buf, bufPtr); } + + DoWrite(nl + '='); + + int crcV = crc.Value; + + buf[0] = ((crcV >> 16) & 0xff); + buf[1] = ((crcV >> 8) & 0xff); + buf[2] = (crcV & 0xff); + + Encode(outStream, buf, 3); + + DoWrite(nl); + DoWrite(footerStart); + DoWrite(type); + DoWrite(footerTail); + DoWrite(nl); + + outStream.Flush(); } private void WriteHeaderEntry( |