C# 클래스 Redzen.IO.NonClosingStreamWrapper

Wraps a stream and prevents calls to Close() and Dispose() from being made on it. This is useful for other classes that wrap a stream but have no option to leave the wrapped stream open upon Dispose(), e.g. CryptoStream and BinaryWriter. Note. Later versions of the .NET framework have added a 'leaveOpen' option to some classes. Check before using this class.
상속: Stream
파일 보기 프로젝트 열기: colgreen/Redzen

공개 메소드들

메소드 설명
BeginRead ( byte buffer, int offset, int count, AsyncCallback callback, object state ) : IAsyncResult

Begins an asynchronous read operation.

BeginWrite ( byte buffer, int offset, int count, AsyncCallback callback, object state ) : IAsyncResult

Begins an asynchronous write operation.

Close ( ) : void

This method is not proxied to the underlying stream; instead, the wrapper is marked as unusable for other (non-close/Dispose) operations. The underlying stream is flushed if the wrapper wasn't closed before this call.

CreateObjRef ( Type requestedType ) : ObjRef

Not implemented. Throws NotSupportedException.

EndRead ( IAsyncResult asyncResult ) : int

Waits for the pending asynchronous read to complete.

EndWrite ( IAsyncResult asyncResult ) : void

Ends an asynchronous write operation.

Flush ( ) : void

Flushes the underlying stream.

InitializeLifetimeService ( ) : object

Not implemented. Throws NotSupportedException.

NonClosingStreamWrapper ( Stream stream ) : System

Construct with the provided stream to be wrapped.

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

Reads a sequence of bytes from the underlying stream and advances the position within the stream by the number of bytes read.

ReadByte ( ) : int

Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

Seek ( long offset, SeekOrigin origin ) : long

Sets the position within the current stream.

SetLength ( long value ) : void

Sets the length of the underlying stream.

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

Writes a sequence of bytes to the underlying stream and advances the current position within the stream by the number of bytes written.

WriteByte ( byte value ) : void

Writes a byte to the current position in the stream and advances the position within the stream by one byte.

비공개 메소드들

메소드 설명
CheckClosed ( ) : void

Throws an InvalidOperationException if the wrapper is closed.

메소드 상세

BeginRead() 공개 메소드

Begins an asynchronous read operation.
public BeginRead ( byte buffer, int offset, int count, AsyncCallback callback, object state ) : IAsyncResult
buffer byte The buffer to read the data into.
offset int The byte offset in buffer at which to begin writing data read from the stream.
count int The maximum number of bytes to read.
callback AsyncCallback An optional asynchronous callback, to be called when the read is complete.
state object A user-provided object that distinguishes this particular asynchronous read request from other requests.
리턴 IAsyncResult

BeginWrite() 공개 메소드

Begins an asynchronous write operation.
public BeginWrite ( byte buffer, int offset, int count, AsyncCallback callback, object state ) : IAsyncResult
buffer byte The buffer to write data from.
offset int The byte offset in buffer from which to begin writing.
count int The maximum number of bytes to write.
callback AsyncCallback An optional asynchronous callback, to be called when the write is complete.
state object A user-provided object that distinguishes this particular asynchronous write request from other requests.
리턴 IAsyncResult

Close() 공개 메소드

This method is not proxied to the underlying stream; instead, the wrapper is marked as unusable for other (non-close/Dispose) operations. The underlying stream is flushed if the wrapper wasn't closed before this call.
public Close ( ) : void
리턴 void

CreateObjRef() 공개 메소드

Not implemented. Throws NotSupportedException.
public CreateObjRef ( Type requestedType ) : ObjRef
requestedType System.Type The Type of the object that the new ObjRef will reference.
리턴 System.Runtime.Remoting.ObjRef

EndRead() 공개 메소드

Waits for the pending asynchronous read to complete.
public EndRead ( IAsyncResult asyncResult ) : int
asyncResult IAsyncResult The reference to the pending asynchronous request to finish.
리턴 int

EndWrite() 공개 메소드

Ends an asynchronous write operation.
public EndWrite ( IAsyncResult asyncResult ) : void
asyncResult IAsyncResult A reference to the outstanding asynchronous I/O request.
리턴 void

Flush() 공개 메소드

Flushes the underlying stream.
public Flush ( ) : void
리턴 void

InitializeLifetimeService() 공개 메소드

Not implemented. Throws NotSupportedException.
public InitializeLifetimeService ( ) : object
리턴 object

NonClosingStreamWrapper() 공개 메소드

Construct with the provided stream to be wrapped.
public NonClosingStreamWrapper ( Stream stream ) : System
stream Stream The stream to be wrapped.
리턴 System

Read() 공개 메소드

Reads a sequence of bytes from the underlying stream and advances the position within the stream by the number of bytes read.
public Read ( byte buffer, int offset, int count ) : int
buffer byte An array of bytes. When this method returns, the buffer contains /// the specified byte array with the values between offset and (offset + count- 1) replaced /// by the bytes read from the underlying source.
offset int The zero-based byte offset in buffer at which to begin storing the data /// read from the underlying stream.
count int The maximum number of bytes to be read from the underlying stream.
리턴 int

ReadByte() 공개 메소드

Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
public ReadByte ( ) : int
리턴 int

Seek() 공개 메소드

Sets the position within the current stream.
public Seek ( long offset, SeekOrigin origin ) : long
offset long A byte offset relative to the origin parameter.
origin SeekOrigin A value of type SeekOrigin indicating the reference point used to obtain the new position.
리턴 long

SetLength() 공개 메소드

Sets the length of the underlying stream.
public SetLength ( long value ) : void
value long The desired length of the underlying stream in bytes.
리턴 void

Write() 공개 메소드

Writes a sequence of bytes to the underlying stream and advances the current position within the stream by the number of bytes written.
public Write ( byte buffer, int offset, int count ) : void
buffer byte An array of bytes. This method copies count bytes from buffer to the underlying stream.
offset int The zero-based byte offset in buffer at which to begin copying bytes to the underlying stream.
count int The number of bytes to be written to the underlying stream.
리턴 void

WriteByte() 공개 메소드

Writes a byte to the current position in the stream and advances the position within the stream by one byte.
public WriteByte ( byte value ) : void
value byte The byte to write to the stream.
리턴 void