BaseOutputStream.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.IO;
  5. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO
  6. {
  7. public abstract class BaseOutputStream
  8. : Stream
  9. {
  10. public sealed override bool CanRead { get { return false; } }
  11. public sealed override bool CanSeek { get { return false; } }
  12. public sealed override bool CanWrite { get { return true; } }
  13. #if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER || (UNITY_2021_2_OR_NEWER && (NET_STANDARD_2_0 || NET_STANDARD_2_1))
  14. public override void CopyTo(Stream destination, int bufferSize) { throw new NotSupportedException(); }
  15. #endif
  16. public override void Flush() {}
  17. public sealed override long Length { get { throw new NotSupportedException(); } }
  18. public sealed override long Position
  19. {
  20. get { throw new NotSupportedException(); }
  21. set { throw new NotSupportedException(); }
  22. }
  23. public sealed override int Read(byte[] buffer, int offset, int count) { throw new NotSupportedException(); }
  24. #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
  25. public sealed override int Read(Span<byte> buffer) { throw new NotSupportedException(); }
  26. #endif
  27. public sealed override long Seek(long offset, SeekOrigin origin) { throw new NotSupportedException(); }
  28. public sealed override void SetLength(long value) { throw new NotSupportedException(); }
  29. public override void Write(byte[] buffer, int offset, int count)
  30. {
  31. Streams.ValidateBufferArguments(buffer, offset, count);
  32. for (int i = 0; i < count; ++i)
  33. {
  34. WriteByte(buffer[offset + i]);
  35. }
  36. }
  37. public virtual void Write(params byte[] buffer)
  38. {
  39. Write(buffer, 0, buffer.Length);
  40. }
  41. }
  42. }
  43. #pragma warning restore
  44. #endif