Class SplitStreamContainer
Represents split stream container which contains the stream and provides stream processing routines.
public class SplitStreamContainer : StreamContainer, IDisposable
- Inheritance
-
SplitStreamContainer
- Implements
- Inherited Members
Constructors
SplitStreamContainer(StreamContainer, bool)
Initializes a new instance of the SplitStreamContainer class.
public SplitStreamContainer(StreamContainer stream, bool disposeStream)
Parameters
stream
StreamContainerThe stream container.
disposeStream
boolif set to
true
disposes stream.
SplitStreamContainer(Stream)
Initializes a new instance of the SplitStreamContainer class.
public SplitStreamContainer(Stream stream)
Parameters
stream
StreamThe stream.
SplitStreamContainer(Stream, bool)
Initializes a new instance of the SplitStreamContainer class.
public SplitStreamContainer(Stream stream, bool disposeStream)
Parameters
stream
StreamThe data stream.
disposeStream
boolif set to
true
the stream will be disposed when container is disposed.
Properties
CanRead
Gets a value indicating whether stream supports reading.
public override bool CanRead { get; }
Property Value
- bool
true
if stream supports reading; otherwise,false
.
CanSeek
Gets a value indicating whether stream supports seeking.
public override bool CanSeek { get; }
Property Value
- bool
true
if stream supports seeking; otherwise,false
.
CanWrite
Gets a value indicating whether stream supports writing.
public override bool CanWrite { get; }
Property Value
- bool
true
if stream supports writing; otherwise,false
.
Length
Gets or sets the stream length in bytes. This value is less than the Length by the starting stream position passed in the StreamContainer constructor.
public override long Length { get; set; }
Property Value
- long
The stream length.
Position
Gets or sets the current position within the stream. This value represents offset from the starting stream position passed in the StreamContainer constructor.
public override long Position { get; set; }
Property Value
- long
The current stream position.
Stream
Gets the data stream.
public override Stream Stream { get; }
Property Value
- Stream
The data stream.
SyncRoot
Gets an object that can be used to synchronize access to the synchronized resource.
public object SyncRoot { get; }
Property Value
- object
The object that can be used to synchronize access to the synchronized resource.
Methods
DisposeStream()
Disposes the stream.
protected override void DisposeStream()
Flush()
Clears all buffers for this stream and causes any buffered data to be written to the underlying device.
public override void Flush()
Insert(int, StreamContainer, bool)
Inserts the stream container into specified position.
public void Insert(int position, StreamContainer stream, bool disposeStream)
Parameters
position
intThe position to insert to.
stream
StreamContainerThe stream container to insert.
disposeStream
boolif set to
true
disposes stream.
Exceptions
- FrameworkException
Framework exception
Read(byte[])
Reads bytes to fill the specified bytes buffer.
public override int Read(byte[] bytes)
Parameters
bytes
byte[]The bytes to fill.
Returns
- int
The number of bytes read. This value can be less than the number of bytes in the buffer if there is not enough bytes in the stream.
Read(byte[], int, int)
Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
public override int Read(byte[] buffer, int offset, int count)
Parameters
buffer
byte[]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.offset
intThe zero-based byte offset in
buffer
at which to begin storing the data read from the current stream.count
intThe maximum number of bytes to be read from the current stream.
Returns
- int
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.
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.
public override int ReadByte()
Returns
- int
The unsigned byte cast to an Int32, or -1 if at the end of the stream.
ReleaseManagedResources()
Releases the managed resources. Make sure no unmanaged resources are released here, since they may have been already released.
protected override void ReleaseManagedResources()
Save(Stream, int, long)
Saves (copies) the stream's data to the specified stream.
public override void Save(Stream destinationStream, int bufferSize, long length)
Parameters
destinationStream
StreamThe stream to save the data to.
bufferSize
intThe buffer size.
length
longThe stream data length to copy. By default the length is set to Length value.
Seek(long, SeekOrigin)
Sets the position within the current stream.
public override long Seek(long offset, SeekOrigin origin)
Parameters
offset
longA byte offset relative to the
origin
parameter. This value represents offset from the starting stream position passed in the StreamContainer constructor.origin
SeekOriginA value of type SeekOrigin indicating the reference point used to obtain the new position.
Returns
- long
The new position within the current stream.
SeekBegin()
Sets the stream position to the beginning of the stream. This value represents offset from the starting stream position passed in the StreamContainer constructor.
public override void SeekBegin()
ToBytes()
Converts the stream data to the byte array.
public override byte[] ToBytes()
Returns
ToBytes(long, long)
Converts the stream data to the byte array.
public override byte[] ToBytes(long position, long bytesCount)
Parameters
Returns
Write(byte[])
Writes all of the specified bytes to the stream.
public override void Write(byte[] bytes)
Parameters
bytes
byte[]The bytes to write.
Write(byte[], int, int)
Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
public override void Write(byte[] buffer, int offset, int count)
Parameters
buffer
byte[]An array of bytes. This method copies
count
bytes frombuffer
to the current stream.offset
intThe zero-based byte offset in
buffer
at which to begin copying bytes to the current stream.count
intThe number of bytes to be written to the current stream.
WriteByte(byte)
Writes a byte to the current position in the stream and advances the position within the stream by one byte.
public override void WriteByte(byte value)
Parameters
value
byteThe byte to write to the stream.