CountingStream
Represents a stream wrapper that counts the bytes read from and written to the underlying stream.
Наследует: Stream
Конструкторы
public CountingStream(Stream underlying, bool leaveOpen)
countingStream = CountingStream(underlying, leaveOpen)
Represents a stream wrapper that counts the bytes read from and written to the underlying stream.
- underlying
- The underlying stream to wrap.
- leaveOpen
- true to leave the underlying stream open after disposing; otherwise, false.
Свойства
public override bool CanRead { get; }
value = countingStream.CanRead
Gets a value indicating whether the current stream supports reading.
public override bool CanSeek { get; }
value = countingStream.CanSeek
Gets a value indicating whether the current stream supports seeking.
public override bool CanWrite { get; }
value = countingStream.CanWrite
Gets a value indicating whether the current stream supports writing.
public override long Length { get; }
value = countingStream.Length
Gets the difference between the maximum and minimum values of the range.
public override long Position { get; set; }
value = countingStream.Position
countingStream.Position = value
Current position value.
public long ReadCount { get; }
value = countingStream.ReadCount
Gets the total number of bytes read from the underlying stream.
public override int ReadTimeout { get; set; }
value = countingStream.ReadTimeout
countingStream.ReadTimeout = value
The timeout of reading data. The default value is Zero.
public long WriteCount { get; }
value = countingStream.WriteCount
Gets the total number of bytes written to the underlying stream.
public override int WriteTimeout { get; set; }
value = countingStream.WriteTimeout
countingStream.WriteTimeout = value
The timeout of sending data. The default value is Zero.
Методы
protected override void Dispose(bool disposing)
countingStream.Dispose(disposing)
Disposes the command resources.
- disposing
- True if disposing managed resources.
public override void Flush()
countingStream.Flush()
Flushes the current byte to the underlying stream and resets the buffer.
public override Task FlushAsync(CancellationToken cancellationToken)
result = countingStream.FlushAsync(cancellationToken)
Flushes the stream asynchronously.
- cancellationToken
- CancellationToken
Возвращает: Task
public override int Read(byte[] buffer, int offset, int count)
result = countingStream.Read(buffer, offset, count)
Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
- buffer
- An array of bytes. When this method returns, the buffer contains the specified byte array with the values between and ( + - 1) replaced by the bytes read from the current source.
- offset
- The zero-based byte offset in at which to begin storing the data read from the current stream.
- count
- The maximum number of bytes to be read from the current stream.
Возвращает: The total number of bytes read into the buffer.
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
result = countingStream.ReadAsync(buffer, offset, count, cancellationToken)
public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken)
result = countingStream.ReadAsync(buffer, cancellationToken)
public override int ReadByte()
result = countingStream.ReadByte()
Reads a byte from the current position and advances the position by 1 byte.
Возвращает: The byte at the current position.
public override long Seek(long offset, SeekOrigin origin)
result = countingStream.Seek(offset, origin)
When overridden in a derived class, sets the position within the current stream.
- offset
- A byte offset relative to the parameter.
- origin
- A value of type SeekOrigin indicating the reference point used to obtain the new position.
Возвращает: The new position within the current stream.
public override void SetLength(long value)
countingStream.SetLength(value)
When overridden in a derived class, sets the length of the current stream.
- value
- The desired length of the current stream in bytes.
public override void Write(byte[] buffer, int offset, int count)
countingStream.Write(buffer, offset, count)
Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
- buffer
- An array of bytes. This method copies bytes from to the current stream.
- offset
- The zero-based byte offset in at which to begin copying bytes to the current stream.
- count
- The number of bytes to be written to the current stream.
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
result = countingStream.WriteAsync(buffer, offset, count, cancellationToken)
public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken)
result = countingStream.WriteAsync(buffer, cancellationToken)
public override void WriteByte(byte value)
countingStream.WriteByte(value)
Writes a byte value to the span at the current position and advances the position.
- value
- The byte value to write.