CountingStream

Ecng.IO

Represents a stream wrapper that counts the bytes read from and written to the underlying stream.

Наследует: Stream

Конструкторы

CountingStream
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.

Свойства

CanRead
public override bool CanRead { get; }
value = countingStream.CanRead

Gets a value indicating whether the current stream supports reading.

CanSeek
public override bool CanSeek { get; }
value = countingStream.CanSeek

Gets a value indicating whether the current stream supports seeking.

CanWrite
public override bool CanWrite { get; }
value = countingStream.CanWrite

Gets a value indicating whether the current stream supports writing.

Length
public override long Length { get; }
value = countingStream.Length

Gets the difference between the maximum and minimum values of the range.

Position
public override long Position { get; set; }
value = countingStream.Position
countingStream.Position = value

Current position value.

ReadCount
public long ReadCount { get; }
value = countingStream.ReadCount

Gets the total number of bytes read from the underlying stream.

ReadTimeout
public override int ReadTimeout { get; set; }
value = countingStream.ReadTimeout
countingStream.ReadTimeout = value

The timeout of reading data. The default value is Zero.

WriteCount
public long WriteCount { get; }
value = countingStream.WriteCount

Gets the total number of bytes written to the underlying stream.

WriteTimeout
public override int WriteTimeout { get; set; }
value = countingStream.WriteTimeout
countingStream.WriteTimeout = value

The timeout of sending data. The default value is Zero.

Методы

Dispose
protected override void Dispose(bool disposing)
countingStream.Dispose(disposing)

Disposes the command resources.

disposing
True if disposing managed resources.
Flush
public override void Flush()
countingStream.Flush()

Flushes the current byte to the underlying stream and resets the buffer.

FlushAsync
public override Task FlushAsync(CancellationToken cancellationToken)
result = countingStream.FlushAsync(cancellationToken)

Flushes the stream asynchronously.

cancellationToken
CancellationToken

Возвращает: Task

Read
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.

Read
public override int Read(Span<byte> buffer)
result = countingStream.Read(buffer)
ReadAsync
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
result = countingStream.ReadAsync(buffer, offset, count, cancellationToken)
ReadAsync
public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken)
result = countingStream.ReadAsync(buffer, cancellationToken)
ReadByte
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.

Seek
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.

SetLength
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.
Write
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.
Write
public override void Write(ReadOnlySpan<byte> buffer)
countingStream.Write(buffer)
WriteAsync
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
result = countingStream.WriteAsync(buffer, offset, count, cancellationToken)
WriteAsync
public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken)
result = countingStream.WriteAsync(buffer, cancellationToken)
WriteByte
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.