Show / Hide Table of Contents

Class StreamExtensions

Extension methods for Stream class.

Inheritance
Object
StreamExtensions
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: UnityFx.Async.Extensions
Assembly: UnityFx.Async-netstandard2.0.dll
Syntax
public static class StreamExtensions

Methods

| Improve this Doc View Source

ReadAsync(Stream, Byte[], Int32, Int32)

Asynchronously reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

Declaration
public static IAsyncOperation<int> ReadAsync(this Stream stream, byte[] buffer, int offset, int count)
Parameters
Type Name Description
Stream stream

The stream to read data from.

System.Byte[] buffer

The buffer to write the data into.

Int32 offset

The byte offset in buffer at which to begin writing data from the stream.

Int32 count

The maximum number of bytes to read.

Returns
Type Description
IAsyncOperation<Int32>

An IAsyncOperation<TResult> that represents the asynchronous read operation. The value of the result 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
Type Condition
ArgumentNullException

Thrown if buffer is null.

ArgumentOutOfRangeException

Thrown if offset or count is negative.

ArgumentException

Thrown if the sum of offset and count is larger than the buffer length.

NotSupportedException

Thrown if the stream does not support reading.

InvalidOperationException

Thrown if the stream is currently in use by a previous read operation.

ObjectDisposedException

Thrown if the stream has been disposed.

| Improve this Doc View Source

WriteAsync(Stream, Byte[], Int32, Int32)

Asynchronously writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

Declaration
public static IAsyncOperation WriteAsync(this Stream stream, byte[] buffer, int offset, int count)
Parameters
Type Name Description
Stream stream

The stream to write data to.

System.Byte[] buffer

The buffer to write data from.

Int32 offset

The zero-based byte offset in buffer from which to begin copying bytes to the stream.

Int32 count

The maximum number of bytes to write.

Returns
Type Description
IAsyncOperation

An IAsyncOperation that represents the asynchronous write operation.

Exceptions
Type Condition
ArgumentNullException

Thrown if buffer is null.

ArgumentOutOfRangeException

Thrown if offset or count is negative.

ArgumentException

Thrown if the sum of offset and count is larger than the buffer length.

NotSupportedException

Thrown if the stream does not support writing.

InvalidOperationException

Thrown if the stream is currently in use by a previous write operation.

ObjectDisposedException

Thrown if the stream has been disposed.

  • Improve this Doc
  • View Source
Back to top Copyright (c) 2017-2018 Alexander Bogarsukov