/// <summary>Returns the StreamMode of the underlying stream to the previous mode</summary> public void Dispose() { if (mStream != null) { mStream.StreamMode = mOldMode; mStream = null; } }
/// <summary>Saves the stream's StreamMode so a new one can be specified, but is then later restored to the previous StreamMode, via <see cref="Dispose()"/></summary> /// <param name="stream">The underlying stream for this bookmark</param> /// <param name="newMode"></param> public IKSoftStreamModeBookmark(IKSoftStreamModeable stream, FileAccess newMode) { Contract.Requires(stream != null); Contract.Requires(newMode != 0, "New mode is unset!"); mOldMode = (mStream = stream).StreamMode; mStream.StreamMode = newMode; if (mOldMode == newMode) { mStream = null; } }