98 if (
value >
int.MaxValue)
126 : this(
buffer, writable: true)
194 protected override void Dispose(
bool disposing)
291 int num = position +
count;
375 return (lastReadTask !=
null && lastReadTask.
Result == num) ? lastReadTask : (
_lastReadTask =
Task.FromResult(num));
459 memoryStream.Write(
_buffer, position, num);
471 if (
offset >
int.MaxValue)
515 if (value < 0 || value >
int.MaxValue)
541 return Array.Empty<
byte>();
543 byte[]
array =
GC.AllocateUninitializedArray<
byte>(num);
649 Write(segment.Array, segment.Offset, segment.Count);
static unsafe void Clear(Array array)
static void BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count)
Task< int > _lastReadTask
virtual void WriteTo(Stream stream)
MemoryStream(byte[] buffer, int index, int count)
override long Seek(long offset, SeekOrigin loc)
bool EnsureCapacity(int value)
override Task FlushAsync(CancellationToken cancellationToken)
override Task< int > ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
MemoryStream(byte[] buffer, int index, int count, bool writable)
virtual bool TryGetBuffer(out ArraySegment< byte > buffer)
override ValueTask WriteAsync(ReadOnlyMemory< byte > buffer, CancellationToken cancellationToken=default(CancellationToken))
ReadOnlySpan< byte > InternalReadSpan(int count)
override void SetLength(long value)
override void Write(ReadOnlySpan< byte > buffer)
MemoryStream(int capacity)
int InternalEmulateRead(int count)
MemoryStream(byte[] buffer)
MemoryStream(byte[] buffer, bool writable)
MemoryStream(byte[] buffer, int index, int count, bool writable, bool publiclyVisible)
int InternalGetPosition()
override ValueTask< int > ReadAsync(Memory< byte > buffer, CancellationToken cancellationToken=default(CancellationToken))
override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
override void Dispose(bool disposing)
override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
override void CopyTo(Stream destination, int bufferSize)
byte[] InternalGetBuffer()
virtual byte[] GetBuffer()
override int Read(byte[] buffer, int offset, int count)
override void Write(byte[] buffer, int offset, int count)
override void WriteByte(byte value)
override int Read(Span< byte > buffer)
static void ValidateBufferArguments(byte[] buffer, int offset, int count)
static void ValidateCopyToArguments(Stream destination, int bufferSize)
static byte Min(byte val1, byte val2)
static byte Max(byte val1, byte val2)
static string ArgumentOutOfRange_SmallCapacity
static string IO_SeekBeforeBegin
static string ArgumentOutOfRange_NegativeCapacity
static string ArgumentNull_Stream
static string IO_StreamTooLong
static string NotSupported_MemStreamNotExpandable
static string Argument_InvalidSeekOrigin
static string ArgumentNull_Buffer
static string Argument_InvalidOffLen
static string UnauthorizedAccess_MemStreamBuffer
static string ArgumentOutOfRange_NeedNonNegNum
static string ArgumentOutOfRange_StreamLength
static Task FromException(Exception exception)
static Task FromCanceled(CancellationToken cancellationToken)
static Task CompletedTask
static void ThrowNotSupportedException_UnwritableStream()
static void ThrowEndOfFileException()
static void ThrowObjectDisposedException_StreamClosed(string objectName)
void CopyTo(Span< T > destination)
static ValueTask FromCanceled(CancellationToken cancellationToken)
static ValueTask FromException(Exception exception)