diff options
Diffstat (limited to 'crypto/src/util/io/BaseOutputStream.cs')
-rw-r--r-- | crypto/src/util/io/BaseOutputStream.cs | 53 |
1 files changed, 14 insertions, 39 deletions
diff --git a/crypto/src/util/io/BaseOutputStream.cs b/crypto/src/util/io/BaseOutputStream.cs index 0dbe821de..d9a5b92d6 100644 --- a/crypto/src/util/io/BaseOutputStream.cs +++ b/crypto/src/util/io/BaseOutputStream.cs @@ -1,35 +1,16 @@ using System; -using System.Diagnostics; using System.IO; namespace Org.BouncyCastle.Utilities.IO { - public abstract class BaseOutputStream : Stream + public abstract class BaseOutputStream + : Stream { - private bool closed; - - public sealed override bool CanRead { get { return false; } } + public sealed override bool CanRead { get { return false; } } public sealed override bool CanSeek { get { return false; } } - public sealed override bool CanWrite { get { return !closed; } } - -#if PORTABLE - protected override void Dispose(bool disposing) - { - if (disposing) - { - closed = true; - } - base.Dispose(disposing); - } -#else - public override void Close() - { - closed = true; - base.Close(); - } -#endif + public sealed override bool CanWrite { get { return true; } } - public override void Flush() { } + public override void Flush() {} public sealed override long Length { get { throw new NotSupportedException(); } } public sealed override long Position { @@ -42,28 +23,22 @@ namespace Org.BouncyCastle.Utilities.IO public override void Write(byte[] buffer, int offset, int count) { - Debug.Assert(buffer != null); - Debug.Assert(0 <= offset && offset <= buffer.Length); - Debug.Assert(count >= 0); - - int end = offset + count; + Streams.ValidateBufferArguments(buffer, offset, count); - Debug.Assert(0 <= end && end <= buffer.Length); - - for (int i = offset; i < end; ++i) + for (int i = 0; i < count; ++i) { - this.WriteByte(buffer[i]); + WriteByte(buffer[offset + i]); } } - public virtual void Write(params byte[] buffer) - { - Write(buffer, 0, buffer.Length); - } + public virtual void Write(params byte[] buffer) + { + Write(buffer, 0, buffer.Length); + } - public override void WriteByte(byte b) + public override void WriteByte(byte value) { - Write(new byte[]{ b }, 0, 1); + Write(new byte[]{ value }, 0, 1); } } } |