C# Class CSharpUtils.Streams.SliceStream

Class to create a SliceStream that will slice a base Stream with its own cursor.
Inheritance: ProxyStream
Show file Open project: soywiz/csharputils

Protected Properties

Property Type Description
ThisLength long
ThisPosition long
ThisStart long

Public Methods

Method Description
CreateWithBounds ( Stream BaseStream, long LowerBound, long UpperBound, bool CanWrite = null ) : SliceStream

Creates a SliceStream specifying a start offset and a end offset.

CreateWithLength ( Stream BaseStream, long ThisStart, long ThisLength = -1, bool CanWrite = null ) : SliceStream

Creates a SliceStream specifying a start offset and a length.

Read ( byte buffer, int offset, int count ) : int

Read a chunk from this SliceStream and move its cursor after that chunk. Only will be able to read inside the bounds of this Slice. It won't change the ParentStream cursor.

Seek ( long offset, SeekOrigin origin ) : long

Seeks the SliceStream without altering the original Stream.

SetLength ( long value ) : void

Not implemented.

Write ( byte buffer, int offset, int count ) : void

Writes a chunk from this SliceStream and move its cursor after that chunk. Only will be able to write inside the bounds of this Slice. It won't change the ParentStream cursor.

Protected Methods

Method Description
SliceStream ( Stream BaseStream, long ThisStart, long ThisLength = -1, bool CanWrite = null, bool AllowSliceOutsideHigh = true ) : System

Creates a SliceStream specifying a start offset and a length. Please use CreateWithLength or CreateWithBounds to initialite the object.

Method Details

CreateWithBounds() static public method

Creates a SliceStream specifying a start offset and a end offset.
static public CreateWithBounds ( Stream BaseStream, long LowerBound, long UpperBound, bool CanWrite = null ) : SliceStream
BaseStream Stream Parent Stream
LowerBound long
UpperBound long
CanWrite bool Determines if the Stream will be writtable.
return SliceStream

CreateWithLength() static public method

Creates a SliceStream specifying a start offset and a length.
static public CreateWithLength ( Stream BaseStream, long ThisStart, long ThisLength = -1, bool CanWrite = null ) : SliceStream
BaseStream Stream Base Stream
ThisStart long Starting Offset
ThisLength long Length of the Slice
CanWrite bool Determines if the Stream will be writtable.
return SliceStream

Read() public method

Read a chunk from this SliceStream and move its cursor after that chunk. Only will be able to read inside the bounds of this Slice. It won't change the ParentStream cursor.
public Read ( byte buffer, int offset, int count ) : int
buffer byte ByteArray to write to
offset int Offset of the ByteArray to write to
count int Number of bytes to read
return int

Seek() public method

Seeks the SliceStream without altering the original Stream.
public Seek ( long offset, SeekOrigin origin ) : long
offset long Offset to seek
origin SeekOrigin Origin for the seeking
return long

SetLength() public method

Not implemented.
public SetLength ( long value ) : void
value long
return void

SliceStream() protected method

Creates a SliceStream specifying a start offset and a length. Please use CreateWithLength or CreateWithBounds to initialite the object.
protected SliceStream ( Stream BaseStream, long ThisStart, long ThisLength = -1, bool CanWrite = null, bool AllowSliceOutsideHigh = true ) : System
BaseStream Stream Base Stream
ThisStart long Starting Offset
ThisLength long Length of the Slice
CanWrite bool Determines if the Stream will be writtable.
AllowSliceOutsideHigh bool
return System

Write() public method

Writes a chunk from this SliceStream and move its cursor after that chunk. Only will be able to write inside the bounds of this Slice. It won't change the ParentStream cursor.
public Write ( byte buffer, int offset, int count ) : void
buffer byte ByteArray to read from
offset int Offset of the ByteArray to read from
count int Number of bytes to write
return void

Property Details

ThisLength protected property

Length of this SliceStream.
protected long ThisLength
return long

ThisPosition protected property

Cursor for this SliceStream.
protected long ThisPosition
return long

ThisStart protected property

Start offset of this SliceStream relative to ParentStream.
protected long ThisStart
return long