protected override void Dispose( bool disposing ) { if( disposing ) { if( this.binaryReader.NotNullReference() ) { this.binaryReader.Close(); this.binaryReader = null; this.binarySeekable = null; } } base.Dispose(disposing); }
/// <summary> /// Wraps the specified <see cref="ISeekableBinaryReader"/>, in <see cref="Stream"/>. /// </summary> /// <param name="binaryReader">The <see cref="ISeekableBinaryReader"/> to wrap.</param> /// <param name="canSeek">Seekable streams require this explicit permission, because SetLength always throw a <see cref="NotSupportedException"/>! Use at your own risk.</param> /// <returns>The disposable wrapper created.</returns> public static Stream Wrap( ISeekableBinaryReader binaryReader, bool canSeek ) { return new IBinaryReaderAsStream(binaryReader, canSeek); }
internal IBinaryReaderAsStream( IBinaryReader reader, bool allowSeeking ) { if( reader.NullReference() ) throw new ArgumentNullException().StoreFileLine(); this.binaryReader = reader; this.binarySeekable = allowSeeking ? reader as ISeekableBinaryReader : null; }