Class WindowedStream
A
Namespace: ICSharpCode.SharpZipLib.Tests.TestSupport
Syntax
public class WindowedStream : Stream
Constructors
WindowedStream(Int32, Nullable<CancellationToken>)
Initializes a new instance of the WindowedStream class.
Declaration
public WindowedStream(int size, CancellationToken? token = null)
Parameters
Type | Name | Description |
---|---|---|
Int32 | size | The size. |
Nullable<CancellationToken> | token |
Properties
BytesRead
Gets the bytes read.
Declaration
public long BytesRead { get; }
Property Value
Type | Description |
---|---|
Int64 | The bytes read. |
BytesWritten
Gets the bytes written.
Declaration
public long BytesWritten { get; }
Property Value
Type | Description |
---|---|
Int64 | The bytes written. |
CanRead
When overridden in a derived class, gets a value indicating whether the current stream supports reading.
Declaration
public override bool CanRead { get; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
If the stream is closed, this property returns false.
CanSeek
Gets a value indicating whether the current stream supports seeking.
Declaration
public override bool CanSeek { get; }
Property Value
Type | Description |
---|---|
Boolean |
CanWrite
When overridden in a derived class, gets a value indicating whether the current stream supports writing.
Declaration
public override bool CanWrite { get; }
Property Value
Type | Description |
---|---|
Boolean |
Remarks
If the stream is closed, this property returns false.
IsClosed
Gets a value indicating whether this instance is closed.
Declaration
public bool IsClosed { get; }
Property Value
Type | Description |
---|---|
Boolean |
|
Length
When overridden in a derived class, gets the length in bytes of the stream.
Declaration
public override long Length { get; }
Property Value
Type | Description |
---|---|
Int64 |
Exceptions
Type | Condition |
---|---|
NotSupportedException | A class derived from Stream does not support seeking. |
ObjectDisposedException | Methods were called after the stream was closed. |
Position
When overridden in a derived class, gets or sets the position within the current stream.
Declaration
public override long Position { get; set; }
Property Value
Type | Description |
---|---|
Int64 |
Exceptions
Type | Condition |
---|---|
IOException | An I/O error occurs. |
NotSupportedException | The stream does not support seeking. |
ObjectDisposedException | Methods were called after the stream was closed. |
Methods
Dispose(Boolean)
Releases the unmanaged resources used by the
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. |
Flush()
When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.
Declaration
public override void Flush()
Exceptions
Type | Condition |
---|---|
IOException | An I/O error occurs. |
Read(Byte[], Int32, Int32)
When overridden in a derived class, 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 | An array of bytes. When this method returns, the buffer contains the specified byte array with the values between |
Int32 | offset | The zero-based byte offset in |
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. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached. |
Exceptions
Type | Condition |
---|---|
ArgumentException | The sum of |
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
IOException | An I/O error occurs. |
NotSupportedException | The stream does not support reading. |
ObjectDisposedException | Methods were called after the stream was closed. |
Seek(Int64, SeekOrigin)
Not supported, throws NotSupportedException.
Declaration
public override long Seek(long offset, SeekOrigin origin)
Parameters
Type | Name | Description |
---|---|---|
Int64 | offset | A byte offset relative to the |
SeekOrigin | origin | A value of type SeekOrigin indicating the reference point used to obtain the new position. |
Returns
Type | Description |
---|---|
Int64 |
Exceptions
Type | Condition |
---|---|
NotSupportedException | The stream does not support seeking, such as if the stream is constructed from a pipe or console output. |
SetLength(Int64)
Not supported, throws NotSupportedException.
Declaration
public override void SetLength(long value)
Parameters
Type | Name | Description |
---|---|---|
Int64 | value | The desired length of the current stream in bytes. |
Exceptions
Type | Condition |
---|---|
NotSupportedException | The stream does not support both writing and seeking, such as if the stream is constructed from a pipe or console output. |
Write(Byte[], Int32, Int32)
Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Declaration
public override void Write(byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | buffer | An array of bytes. This method copies |
Int32 | offset | The zero-based byte offset in |
Int32 | count | The number of bytes to be written to the current stream. |
Exceptions
Type | Condition |
---|---|
ArgumentException | The sum of |
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
IOException | An I/O error occurs. |
NotSupportedException | The stream does not support writing. |
ObjectDisposedException | Methods were called after the stream was closed. |