internal StreamAsIBinaryStream( Stream stream ) { if( stream.NullReference() ) throw new ArgumentNullException().StoreFileLine(); if( !stream.CanRead ) throw new ArgumentException("Stream not readable!").StoreFileLine(); if( !stream.CanWrite ) throw new ArgumentException("Stream not writable!").StoreFileLine(); if( !stream.CanSeek ) throw new ArgumentException("Stream not seekable!").StoreFileLine(); this.stream = stream; this.reader = new BinaryStreamReaderLE(this.stream); this.writer = new BinaryStreamWriterLE(this.stream); }
/// <summary> /// Wraps the specified <see cref="Stream"/>, in a disposable <see cref="IBinaryReader"/>. /// </summary> /// <param name="stream">The <see cref="Stream"/> to wrap.</param> /// <returns>The disposable wrapper created.</returns> public static IBinaryReader ToBinaryReader( Stream stream ) { if( stream.NullReference() ) throw new ArgumentNullException().StoreFileLine(); if( stream.CanSeek ) return new StreamAsIBinaryReader.Seekable(stream); else return new StreamAsIBinaryReader(stream); }