Class PartialStream
Defines a System.IO.Stream that only covers parts of another stream
Inheritance
Implements
Inherited Members
Namespace: ImageVault.Core.Lib.IO
Assembly: ImageVault.Core.dll
Syntax
public class PartialStream : Stream, IDisposable
Constructors
PartialStream(Stream, Int64, Int64)
Initializes a new instance of the PartialStream class.
Declaration
public PartialStream(Stream stream, long start, long length)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The System.IO.Stream to wrap |
System.Int64 | start | The start position of the partial stream |
System.Int64 | length | The length of the partial stream |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | If |
Properties
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 |
---|---|
System.Boolean |
Overrides
CanSeek
When overridden in a derived class, gets a value indicating whether the current stream supports seeking.
Declaration
public override bool CanSeek { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
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 |
---|---|
System.Boolean |
Overrides
Length
Gets the length of the stream.
Declaration
public override long Length { get; }
Property Value
Type | Description |
---|---|
System.Int64 |
Overrides
Position
Gets or sets the current position of the stream.
Declaration
public override long Position { get; set; }
Property Value
Type | Description |
---|---|
System.Int64 |
Overrides
Methods
Dispose(Boolean)
Releases the resources used by the PartialStream.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | Set to true to release both managed and unmanaged resources; false to release only unmanaged resources. |
Overrides
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()
Overrides
Exceptions
Type | Condition |
---|---|
System.IO.IOException | An I/O error occurs. |
Read(Byte[], Int32, Int32)
Reads data from the partial stream
Declaration
public override int Read(byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source. |
System.Int32 | offset | The zero-based byte offset in buffer at which to begin storing the data read from the current stream. |
System.Int32 | count | The maximum number of bytes to be read from the current stream. |
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
Seek(Int64, SeekOrigin)
Sets the new position in the stream.
Declaration
public override long Seek(long offset, SeekOrigin origin)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | offset | A byte offset relative to the origin parameter. |
System.IO.SeekOrigin | origin | A value of type System.IO.SeekOrigin indicating the reference point used to obtain the new position. |
Returns
Type | Description |
---|---|
System.Int64 | The new position within the current stream. |
Overrides
Exceptions
Type | Condition |
---|---|
System.ApplicationException | If unable to handle SeekOrigin. |
SetLength(Int64)
Attempts to set a new length, but since the length of the partial stream was locked when the stream was constructed, this method will throw a System.NotSupportedException exception.
Declaration
public override void SetLength(long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The new length of the stream. This parameter is ignored. |
Overrides
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Thrown in all cases because the length is fixed. |
Write(Byte[], Int32, Int32)
When overridden in a derived class, 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 |
---|---|---|
System.Byte[] | buffer | An array of bytes. This method copies count bytes from buffer to the current stream. |
System.Int32 | offset | The zero-based byte offset in buffer at which to begin copying bytes to the current stream. |
System.Int32 | count | The number of bytes to be written to the current stream. |
Overrides
Exceptions
Type | Condition |
---|---|
System.IO.IOException | If unable to write to stream, would write past end of partial stream. |