Show / Hide Table of Contents

Class StreamSegment

Represents a portion of the underlying stream in the its of the read-onyl view.

Inheritance
Object
StreamSegment
Namespace: DotNext.IO
Assembly: DotNext.dll
Syntax
public sealed class StreamSegment : Stream
Remarks

The segmentation is supported only for seekable streams.

Constructors

| Improve this Doc View Source

StreamSegment(Stream, Boolean)

Initializes a new segment of the specified stream.

Declaration
public StreamSegment(Stream stream, bool leaveOpen = true)
Parameters
Type Name Description
Stream stream

The underlying stream represented by the segment.

Boolean leaveOpen

true to leave stream open after the object is disposed; otherwise, false.

Properties

| Improve this Doc View Source

BaseStream

Gets underlying stream.

Declaration
public Stream BaseStream { get; }
Property Value
Type Description
Stream
| Improve this Doc View Source

CanRead

Gets a value indicating whether the current stream supports reading.

Declaration
public override bool CanRead { get; }
Property Value
Type Description
Boolean

true if the stream supports reading; otherwise, false.

| Improve this Doc View Source

CanSeek

Gets a value indicating whether the current stream supports seeking.

Declaration
public override bool CanSeek { get; }
Property Value
Type Description
Boolean

true if the stream supports seeking; otherwise, false.

| Improve this Doc View Source

CanTimeout

Gets a value that determines whether the current stream can time out.

Declaration
public override bool CanTimeout { get; }
Property Value
Type Description
Boolean

A value that determines whether the current stream can time out.

| Improve this Doc View Source

CanWrite

Gets a value indicating whether the current stream supports writing.

Declaration
public override bool CanWrite { get; }
Property Value
Type Description
Boolean

Always false.

| Improve this Doc View Source

Length

Gets the length in bytes of the stream.

Declaration
public override long Length { get; }
Property Value
Type Description
Int64
| Improve this Doc View Source

Position

Gets or sets relative position from the beginning of this segment.

Declaration
public override long Position { get; set; }
Property Value
Type Description
Int64
| Improve this Doc View Source

ReadTimeout

Gets or sets a value, in miliseconds, that determines how long the stream will attempt to read before timing out.

Declaration
public override int ReadTimeout { get; set; }
Property Value
Type Description
Int32

A value, in miliseconds, that determines how long the stream will attempt to read before timing out.

| Improve this Doc View Source

WriteTimeout

Gets or sets a value, in miliseconds, that determines how long the stream will attempt to write before timing out.

Declaration
public override int WriteTimeout { get; set; }
Property Value
Type Description
Int32

A value, in miliseconds, that determines how long the stream will attempt to write before timing out.

Methods

| Improve this Doc View Source

Adjust(Int64, Int64)

Establishes segment bounds.

Declaration
public void Adjust(long offset, long length)
Parameters
Type Name Description
Int64 offset

The offset in the underlying stream.

Int64 length

The length of the segment.

Remarks

This method modifies property of the underlying stream.

| Improve this Doc View Source

Dispose(Boolean)

Releases the unmanaged resources used by this stream and optionally releases the managed resources.

Declaration
protected override void Dispose(bool disposing)
Parameters
Type Name Description
Boolean disposing

true to release both managed and unmanaged resources; false to release only unmanaged resources.

| Improve this Doc View Source

Flush()

Clears all buffers for this stream and causes any buffered data to be written to the underlying device.

Declaration
public override void Flush()
| Improve this Doc View Source

FlushAsync(CancellationToken)

Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying device, and monitors cancellation requests.

Declaration
public override Task FlushAsync(CancellationToken token = null)
Parameters
Type Name Description
CancellationToken token

The token to monitor for cancellation requests.

Returns
Type Description
Task

A task that represents the asynchronous flush operation.

| Improve this Doc View Source

Read(Byte[], Int32, Int32)

Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

Declaration
public override int Read(byte[] buffer, int offset, int count)
Parameters
Type Name Description
Byte[] buffer

Contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.

Int32 offset

The zero-based byte offset in buffer at which to begin storing the data read from the current stream.

Int32 count

The maximum number of bytes to be read from the current stream.

Returns
Type Description
Int32

The total number of bytes read into the buffer.

| Improve this Doc View Source

ReadAsync(Byte[], Int32, Int32, CancellationToken)

Asynchronously reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

Declaration
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken token = null)
Parameters
Type Name Description
Byte[] buffer

Contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.

Int32 offset

The zero-based byte offset in buffer at which to begin storing the data read from the current stream.

Int32 count

The maximum number of bytes to be read from the current stream.

CancellationToken token

The token to monitor for cancellation requests.

Returns
Type Description
Task<Int32>

The total number of bytes read into the buffer.

| Improve this Doc View Source

ReadByte()

Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

Declaration
public override int ReadByte()
Returns
Type Description
Int32

The unsigned byte cast to an Int32, or -1 if at the end of the stream.

| Improve this Doc View Source

Seek(Int64, SeekOrigin)

Sets the position within the current stream.

Declaration
public override long Seek(long offset, SeekOrigin origin)
Parameters
Type Name Description
Int64 offset

A byte offset relative to the origin parameter.

SeekOrigin origin

The reference point used to obtain the new position.

Returns
Type Description
Int64

The new position within the current stream.

| Improve this Doc View Source

SetLength(Int64)

Sets the length of the current stream.

Declaration
public override void SetLength(long value)
Parameters
Type Name Description
Int64 value

The desired length of the current stream in bytes.

| Improve this Doc View Source

Write(Byte[], Int32, Int32)

This method is not supported.

Declaration
public override void Write(byte[] buffer, int offset, int count)
Parameters
Type Name Description
Byte[] buffer
Int32 offset
Int32 count
| Improve this Doc View Source

WriteAsync(Byte[], Int32, Int32, CancellationToken)

This method is not supported.

Declaration
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken token = null)
Parameters
Type Name Description
Byte[] buffer
Int32 offset
Int32 count
CancellationToken token
Returns
Type Description
Task
| Improve this Doc View Source

WriteByte(Byte)

This method is not supported.

Declaration
public override void WriteByte(byte value)
Parameters
Type Name Description
Byte value

The byte to write to the stream.

Extension Methods

AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireUpgradeableReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireUpgradeableReadLockAsync<T>(T, CancellationToken)
ExpressionBuilder.Const<T>(T)
ObjectExtensions.GetUserData<T>(T)
ObjectExtensions.IsOneOf<T>(T, IEnumerable<T>)
ObjectExtensions.IsOneOf<T>(T, T[])
ObjectExtensions.Decompose<T, R1, R2>(T, Func<T, R1>, Func<T, R2>, out R1, out R2)
ObjectExtensions.Decompose<T, R1, R2>(T, ValueFunc<T, R1>, ValueFunc<T, R2>, out R1, out R2)
ObjectExtensions.Decompose<T, R1, R2>(T, Func<T, R1>, Func<T, R2>)
ObjectExtensions.Decompose<T, R1, R2>(T, ValueFunc<T, R1>, ValueFunc<T, R2>)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX