diff --git a/Rebracer.xml b/Rebracer.xml index 928d1a0..6ce2ef7 100644 --- a/Rebracer.xml +++ b/Rebracer.xml @@ -22,9 +22,31 @@ + true + true + true + true + true + true 4 2 false + 58 + true + true + true + true + true + true + true + true + true + true + 4 + false + false + false + true 0 diff --git a/SystemInterface/IO/IStream.cs b/SystemInterface/IO/IStream.cs index a8f0b64..2802587 100644 --- a/SystemInterface/IO/IStream.cs +++ b/SystemInterface/IO/IStream.cs @@ -1,6 +1,8 @@ using System; using System.IO; using System.Runtime.InteropServices; +using System.Threading; +using System.Threading.Tasks; namespace SystemInterface.IO { @@ -101,6 +103,20 @@ namespace SystemInterface.IO /// void Flush(); + // + // Summary: + // Asynchronously clears all buffers for this stream and causes any buffered data + // to be written to the underlying device. + // + // Returns: + // A task that represents the asynchronous flush operation. + // + // Exceptions: + // T:System.ObjectDisposedException: + // The stream has been disposed. + [ComVisible(false)] + Task FlushAsync(); + /// /// When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. /// @@ -110,6 +126,96 @@ namespace SystemInterface.IO /// The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached. int Read([In, Out] byte[] buffer, int offset, int count); + // + // Summary: + // Asynchronously reads a sequence of bytes from the current stream and advances + // the position within the stream by the number of bytes read. + // + // Parameters: + // buffer: + // The buffer to write the data into. + // + // offset: + // The byte offset in buffer at which to begin writing data from the stream. + // + // count: + // The maximum number of bytes to read. + // + // Returns: + // A task that represents the asynchronous read operation. The value of the TResult + // parameter contains the total number of bytes read into the buffer. The result + // value can be less than the number of bytes requested if the number of bytes currently + // available is less than the requested number, or it can be 0 (zero) if the end + // of the stream has been reached. + // + // Exceptions: + // T:System.ArgumentNullException: + // buffer is null. + // + // T:System.ArgumentOutOfRangeException: + // offset or count is negative. + // + // T:System.ArgumentException: + // The sum of offset and count is larger than the buffer length. + // + // T:System.NotSupportedException: + // The stream does not support reading. + // + // T:System.ObjectDisposedException: + // The stream has been disposed. + // + // T:System.InvalidOperationException: + // The stream is currently in use by a previous read operation. + [ComVisible(false)] + Task ReadAsync(byte[] buffer, int offset, int count); + + // + // Summary: + // Asynchronously reads a sequence of bytes from the current stream, advances the + // position within the stream by the number of bytes read, and monitors cancellation + // requests. + // + // Parameters: + // buffer: + // The buffer to write the data into. + // + // offset: + // The byte offset in buffer at which to begin writing data from the stream. + // + // count: + // The maximum number of bytes to read. + // + // cancellationToken: + // The token to monitor for cancellation requests. The default value is System.Threading.CancellationToken.None. + // + // Returns: + // A task that represents the asynchronous read operation. The value of the TResult + // parameter contains the total number of bytes read into the buffer. The result + // value can be less than the number of bytes requested if the number of bytes currently + // available is less than the requested number, or it can be 0 (zero) if the end + // of the stream has been reached. + // + // Exceptions: + // T:System.ArgumentNullException: + // buffer is null. + // + // T:System.ArgumentOutOfRangeException: + // offset or count is negative. + // + // T:System.ArgumentException: + // The sum of offset and count is larger than the buffer length. + // + // T:System.NotSupportedException: + // The stream does not support reading. + // + // T:System.ObjectDisposedException: + // The stream has been disposed. + // + // T:System.InvalidOperationException: + // The stream is currently in use by a previous read operation. + [ComVisible(false)] + Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken); + /// /// 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. /// @@ -145,6 +251,91 @@ namespace SystemInterface.IO /// The number of bytes to be written to the current stream. void Write(byte[] buffer, int offset, int count); + // + // Summary: + // Asynchronously writes a sequence of bytes to the current stream and advances + // the current position within this stream by the number of bytes written. + // + // Parameters: + // buffer: + // The buffer to write data from. + // + // offset: + // The zero-based byte offset in buffer from which to begin copying bytes to the + // stream. + // + // count: + // The maximum number of bytes to write. + // + // Returns: + // A task that represents the asynchronous write operation. + // + // Exceptions: + // T:System.ArgumentNullException: + // buffer is null. + // + // T:System.ArgumentOutOfRangeException: + // offset or count is negative. + // + // T:System.ArgumentException: + // The sum of offset and count is larger than the buffer length. + // + // T:System.NotSupportedException: + // The stream does not support writing. + // + // T:System.ObjectDisposedException: + // The stream has been disposed. + // + // T:System.InvalidOperationException: + // The stream is currently in use by a previous write operation. + [ComVisible(false)] + Task WriteAsync(byte[] buffer, int offset, int count); + + // + // Summary: + // Asynchronously writes a sequence of bytes to the current stream, advances the + // current position within this stream by the number of bytes written, and monitors + // cancellation requests. + // + // Parameters: + // buffer: + // The buffer to write data from. + // + // offset: + // The zero-based byte offset in buffer from which to begin copying bytes to the + // stream. + // + // count: + // The maximum number of bytes to write. + // + // cancellationToken: + // The token to monitor for cancellation requests. The default value is System.Threading.CancellationToken.None. + // + // Returns: + // A task that represents the asynchronous write operation. + // + // Exceptions: + // T:System.ArgumentNullException: + // buffer is null. + // + // T:System.ArgumentOutOfRangeException: + // offset or count is negative. + // + // T:System.ArgumentException: + // The sum of offset and count is larger than the buffer length. + // + // T:System.NotSupportedException: + // The stream does not support writing. + // + // T:System.ObjectDisposedException: + // The stream has been disposed. + // + // T:System.InvalidOperationException: + // The stream is currently in use by a previous write operation. + [ComVisible(false)] + Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken); + + /// /// Writes a byte to the current position in the stream and advances the position within the stream by one byte. /// diff --git a/SystemWrapper/IO/FileStreamWrap.cs b/SystemWrapper/IO/FileStreamWrap.cs index ac28d3b..ad055f5 100644 --- a/SystemWrapper/IO/FileStreamWrap.cs +++ b/SystemWrapper/IO/FileStreamWrap.cs @@ -3,6 +3,8 @@ using System.IO; using System.Runtime.InteropServices; using System.Security.AccessControl; using System.Security.Permissions; +using System.Threading; +using System.Threading.Tasks; using SystemInterface.IO; using SystemInterface.Microsoft.Win32.SafeHandles; using SystemInterface.Security.AccessControl; @@ -604,5 +606,30 @@ namespace SystemWrapper.IO fileStreamWraps[i] = new FileStreamWrap(fileStreams[i]); return fileStreamWraps; } + + public async Task FlushAsync() + { + await FileStreamInstance.FlushAsync(); + } + + public async Task ReadAsync(byte[] buffer, int offset, int count) + { + return await FileStreamInstance.ReadAsync(buffer, offset, count); + } + + public async Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + return await FileStreamInstance.ReadAsync(buffer, offset, count, cancellationToken); + } + + public async Task WriteAsync(byte[] buffer, int offset, int count) + { + await FileStreamInstance.WriteAsync(buffer, offset, count); + } + + public async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + await FileStreamInstance.WriteAsync(buffer, offset, count, cancellationToken); + } } -} \ No newline at end of file +} diff --git a/SystemWrapper/IO/MemoryStreamWrap.cs b/SystemWrapper/IO/MemoryStreamWrap.cs index 4c2cf76..63c958e 100644 --- a/SystemWrapper/IO/MemoryStreamWrap.cs +++ b/SystemWrapper/IO/MemoryStreamWrap.cs @@ -2,6 +2,8 @@ using System; using System.IO; using System.Runtime.InteropServices; using System.Security.Permissions; +using System.Threading; +using System.Threading.Tasks; using SystemInterface.IO; namespace SystemWrapper.IO @@ -407,5 +409,30 @@ namespace SystemWrapper.IO { MemoryStreamInstance.Dispose(); } + + public async Task FlushAsync() + { + await MemoryStreamInstance.FlushAsync(); + } + + public async Task ReadAsync(byte[] buffer, int offset, int count) + { + return await MemoryStreamInstance.ReadAsync(buffer, offset, count); + } + + public async Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + return await MemoryStreamInstance.ReadAsync(buffer, offset, count, cancellationToken); + } + + public async Task WriteAsync(byte[] buffer, int offset, int count) + { + await MemoryStreamInstance.WriteAsync(buffer, offset, count); + } + + public async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + await MemoryStreamInstance.WriteAsync(buffer, offset, count, cancellationToken); + } } } diff --git a/SystemWrapper/IO/StreamWrap.cs b/SystemWrapper/IO/StreamWrap.cs index c7450db..08e4cee 100644 --- a/SystemWrapper/IO/StreamWrap.cs +++ b/SystemWrapper/IO/StreamWrap.cs @@ -2,7 +2,8 @@ { using System; using System.IO; - + using System.Threading; + using System.Threading.Tasks; using SystemInterface.IO; /// @@ -249,6 +250,11 @@ this.StreamInstance.Flush(); } + public async Task FlushAsync() + { + await StreamInstance.FlushAsync(); + } + /// /// When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the /// number of bytes read. @@ -274,6 +280,16 @@ return this.StreamInstance.Read(buffer, offset, count); } + public async Task ReadAsync(byte[] buffer, int offset, int count) + { + return await StreamInstance.ReadAsync(buffer, offset, count); + } + + public async Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + return await StreamInstance.ReadAsync(buffer, offset, count, cancellationToken); + } + /// /// 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. /// @@ -348,6 +364,16 @@ this.StreamInstance.Write(buffer, offset, count); } + public async Task WriteAsync(byte[] buffer, int offset, int count) + { + await StreamInstance.WriteAsync(buffer, offset, count); + } + + public async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + await StreamInstance.WriteAsync(buffer, offset, count, cancellationToken); + } + /// /// Writes a byte to the current position in the stream and advances the position within the stream by one byte. /// @@ -361,4 +387,4 @@ #endregion } -} \ No newline at end of file +}