diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-06-30 10:33:35 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-06-30 10:33:35 +0700 |
commit | 1d31e90574c9dc8060670773a99c8a9ea5b2827c (patch) | |
tree | 50c520a5e0bd14dab5e5ad85cdc5dd5e8928ff56 /crypto/src/util | |
parent | Cleanup Stream disposing in Bcpg (diff) | |
download | BouncyCastle.NET-ed25519-1d31e90574c9dc8060670773a99c8a9ea5b2827c.tar.xz |
Some PORTABLE cleanup
Diffstat (limited to 'crypto/src/util')
-rw-r--r-- | crypto/src/util/Strings.cs | 4 | ||||
-rw-r--r-- | crypto/src/util/io/FilterStream.cs | 35 |
2 files changed, 19 insertions, 20 deletions
diff --git a/crypto/src/util/Strings.cs b/crypto/src/util/Strings.cs index 1d0c94611..baee573be 100644 --- a/crypto/src/util/Strings.cs +++ b/crypto/src/util/Strings.cs @@ -48,7 +48,7 @@ namespace Org.BouncyCastle.Utilities public static string FromAsciiByteArray(byte[] bytes) { - return Encoding.ASCII.GetString(bytes, 0, bytes.Length); + return Encoding.ASCII.GetString(bytes); } public static byte[] ToAsciiByteArray(char[] cs) @@ -63,7 +63,7 @@ namespace Org.BouncyCastle.Utilities public static string FromUtf8ByteArray(byte[] bytes) { - return Encoding.UTF8.GetString(bytes, 0, bytes.Length); + return Encoding.UTF8.GetString(bytes); } public static byte[] ToUtf8ByteArray(char[] cs) diff --git a/crypto/src/util/io/FilterStream.cs b/crypto/src/util/io/FilterStream.cs index a92dee3e5..0db82ec88 100644 --- a/crypto/src/util/io/FilterStream.cs +++ b/crypto/src/util/io/FilterStream.cs @@ -1,13 +1,29 @@ +using System; using System.IO; namespace Org.BouncyCastle.Utilities.IO { - public class FilterStream : Stream + public class FilterStream + : Stream { + protected readonly Stream s; + public FilterStream(Stream s) { + if (s == null) + throw new ArgumentNullException(nameof(s)); + this.s = s; } + protected override void Dispose(bool disposing) + { + if (disposing) + { + s.Dispose(); + } + + base.Dispose(disposing); + } public override bool CanRead { get { return s.CanRead; } @@ -29,22 +45,6 @@ namespace Org.BouncyCastle.Utilities.IO get { return s.Position; } set { s.Position = value; } } -#if PORTABLE - protected override void Dispose(bool disposing) - { - if (disposing) - { - Platform.Dispose(s); - } - base.Dispose(disposing); - } -#else - public override void Close() - { - Platform.Dispose(s); - base.Close(); - } -#endif public override void Flush() { s.Flush(); @@ -73,6 +73,5 @@ namespace Org.BouncyCastle.Utilities.IO { s.WriteByte(value); } - protected readonly Stream s; } } |