protected SliceStream(Stream BaseStream, long ThisStart = 0, long ThisLength = -1, bool? CanWrite = null, bool AllowSliceOutsideHigh = true)
: base(BaseStream, CloseParent: false)
{
if (!BaseStream.CanSeek) throw(new NotImplementedException("ParentStream must be seekable"));
this.ThisPosition = 0;
this.ThisStart = ThisStart;
this.ThisLength = (ThisLength == -1) ? (BaseStream.Length - ThisStart) : ThisLength;
bool ErrorCreating = false;
if ((SliceHigh < SliceLow) || (SliceLow < 0) || (SliceHigh < 0))
{
ErrorCreating = true;
}
if (!AllowSliceOutsideHigh && ((SliceLow > BaseStream.Length) || (SliceHigh > BaseStream.Length)))
{
ErrorCreating = true;
}
if (ErrorCreating)
{
throw (new InvalidOperationException(String.Format("Trying to SliceStream Parent(Length={0}) Slice({1}-{2})", BaseStream.Length, ThisStart, ThisLength)));
}
}