C# Класс ToolBelt.NonClosingStreamWrapper

Wraps a stream for all operations except Close and Dispose, which merely flush the stream and prevent further operations from being carried out using this wrapper.
Наследование: Stream
Показать файл Открыть проект

Открытые методы

Метод Описание
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

Throws a 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

Throws a NotSupportedException.

NonClosingStreamWrapper ( Stream stream ) : System.Runtime.Remoting

Creates a new instance of the class, wrapping the specified stream.

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() публичный Метод

Throws a 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() публичный Метод

Throws a NotSupportedException.
public InitializeLifetimeService ( ) : object
Результат object

NonClosingStreamWrapper() публичный Метод

Creates a new instance of the class, wrapping the specified stream.
stream is null
public NonClosingStreamWrapper ( Stream stream ) : System.Runtime.Remoting
stream Stream The stream to wrap. Must not be null.
Результат System.Runtime.Remoting

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