From aa5f3f0929c50fc942325f18ed7ae48129d4c992 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Sat, 3 Sep 2022 00:36:40 +0700 Subject: Stream modernization --- crypto/src/util/io/TeeInputStream.cs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'crypto/src/util/io/TeeInputStream.cs') diff --git a/crypto/src/util/io/TeeInputStream.cs b/crypto/src/util/io/TeeInputStream.cs index 73ea8fed0..3d45bb4f1 100644 --- a/crypto/src/util/io/TeeInputStream.cs +++ b/crypto/src/util/io/TeeInputStream.cs @@ -18,7 +18,6 @@ namespace Org.BouncyCastle.Utilities.IO this.tee = tee; } -#if PORTABLE protected override void Dispose(bool disposing) { if (disposing) @@ -28,14 +27,6 @@ namespace Org.BouncyCastle.Utilities.IO } base.Dispose(disposing); } -#else - public override void Close() - { - Platform.Dispose(input); - Platform.Dispose(tee); - base.Close(); - } -#endif public override int Read(byte[] buffer, int offset, int count) { @@ -49,7 +40,21 @@ namespace Org.BouncyCastle.Utilities.IO return i; } - public override int ReadByte() +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + public override int Read(Span buffer) + { + int i = input.Read(buffer); + + if (i > 0) + { + tee.Write(buffer[..i]); + } + + return i; + } +#endif + + public override int ReadByte() { int i = input.ReadByte(); -- cgit 1.5.1