Show / Hide Table of Contents

Class RandomAccessStream

Represents a stream over the storage that supports random access.

Inheritance
object
MarshalByRefObject
Stream
ModernStream
RandomAccessStream
Implements
IDisposable
IAsyncDisposable
IFlushable
IValueTaskSource
IValueTaskSource<int>
Inherited Members
ModernStream.Read(byte[], int, int)
ModernStream.ReadAsync(byte[], int, int, CancellationToken)
ModernStream.BeginRead(byte[], int, int, AsyncCallback, object)
ModernStream.EndRead(IAsyncResult)
ModernStream.ReadByte()
ModernStream.Write(byte[], int, int)
ModernStream.WriteByte(byte)
ModernStream.WriteAsync(byte[], int, int, CancellationToken)
ModernStream.BeginWrite(byte[], int, int, AsyncCallback, object)
ModernStream.EndWrite(IAsyncResult)
Stream.Null
Stream.CopyTo(Stream)
Stream.CopyTo(Stream, int)
Stream.CopyToAsync(Stream)
Stream.CopyToAsync(Stream, int)
Stream.CopyToAsync(Stream, CancellationToken)
Stream.CopyToAsync(Stream, int, CancellationToken)
Stream.Dispose()
Stream.Close()
Stream.DisposeAsync()
Stream.Flush()
Stream.FlushAsync()
Stream.FlushAsync(CancellationToken)
Stream.CreateWaitHandle()
Stream.ReadAsync(byte[], int, int)
Stream.ReadExactlyAsync(Memory<byte>, CancellationToken)
Stream.ReadExactlyAsync(byte[], int, int, CancellationToken)
Stream.ReadAtLeastAsync(Memory<byte>, int, bool, CancellationToken)
Stream.WriteAsync(byte[], int, int)
Stream.SetLength(long)
Stream.ReadExactly(Span<byte>)
Stream.ReadExactly(byte[], int, int)
Stream.ReadAtLeast(Span<byte>, int, bool)
Stream.Synchronized(Stream)
Stream.ObjectInvariant()
Stream.ValidateBufferArguments(byte[], int, int)
Stream.ValidateCopyToArguments(Stream, int)
Stream.CanRead
Stream.CanWrite
Stream.CanTimeout
Stream.Length
Stream.ReadTimeout
Stream.WriteTimeout
MarshalByRefObject.GetLifetimeService()
MarshalByRefObject.InitializeLifetimeService()
MarshalByRefObject.MemberwiseClone(bool)
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: DotNext.IO
Assembly: DotNext.IO.dll
Syntax
public abstract class RandomAccessStream : ModernStream, IDisposable, IAsyncDisposable, IFlushable, IValueTaskSource, IValueTaskSource<int>

Constructors

View Source

RandomAccessStream()

Declaration
protected RandomAccessStream()

Properties

View Source

CanSeek

Declaration
public override bool CanSeek { get; }
Property Value
Type Description
bool
Overrides
Stream.CanSeek
View Source

Position

Declaration
public override sealed long Position { get; set; }
Property Value
Type Description
long
Overrides
Stream.Position

Methods

View Source

Dispose(bool)

Declaration
protected override void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing
Overrides
Stream.Dispose(bool)
View Source

Read(Span<byte>)

Declaration
public override sealed int Read(Span<byte> buffer)
Parameters
Type Name Description
Span<byte> buffer
Returns
Type Description
int
Overrides
ModernStream.Read(Span<byte>)
View Source

Read(Span<byte>, long)

Reads bytes to the specified buffer.

Declaration
protected abstract int Read(Span<byte> buffer, long offset)
Parameters
Type Name Description
Span<byte> buffer

The buffer to be modified.

long offset

The offset within the underlying data storage.

Returns
Type Description
int

The number of bytes read.

View Source

ReadAsync(Memory<byte>, long, CancellationToken)

Reads bytes to the specified buffer.

Declaration
protected abstract ValueTask<int> ReadAsync(Memory<byte> buffer, long offset, CancellationToken token)
Parameters
Type Name Description
Memory<byte> buffer

The buffer to be modified.

long offset

The offset within the underlying data storage.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask<int>

The number of bytes read.

View Source

ReadAsync(Memory<byte>, CancellationToken)

Declaration
public override sealed ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken token = default)
Parameters
Type Name Description
Memory<byte> buffer
CancellationToken token
Returns
Type Description
ValueTask<int>
Overrides
ModernStream.ReadAsync(Memory<byte>, CancellationToken)
View Source

Seek(long, SeekOrigin)

Declaration
public override long Seek(long offset, SeekOrigin origin)
Parameters
Type Name Description
long offset
SeekOrigin origin
Returns
Type Description
long
Overrides
Stream.Seek(long, SeekOrigin)
View Source

Write(ReadOnlySpan<byte>)

Declaration
public override sealed void Write(ReadOnlySpan<byte> buffer)
Parameters
Type Name Description
ReadOnlySpan<byte> buffer
Overrides
ModernStream.Write(ReadOnlySpan<byte>)
View Source

Write(ReadOnlySpan<byte>, long)

Writes the bytes at the specified offset.

Declaration
protected abstract void Write(ReadOnlySpan<byte> buffer, long offset)
Parameters
Type Name Description
ReadOnlySpan<byte> buffer

The buffer to write.

long offset

The offset within the underlying data storage.

View Source

WriteAsync(ReadOnlyMemory<byte>, long, CancellationToken)

Writes the bytes at the specified offset.

Declaration
protected abstract ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, long offset, CancellationToken token)
Parameters
Type Name Description
ReadOnlyMemory<byte> buffer

The buffer to write.

long offset

The offset within the underlying data storage.

CancellationToken token

The token that can be used to cancel the operation.

Returns
Type Description
ValueTask

The task representing asynchronous operation.

View Source

WriteAsync(ReadOnlyMemory<byte>, CancellationToken)

Declaration
public override sealed ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken token = default)
Parameters
Type Name Description
ReadOnlyMemory<byte> buffer
CancellationToken token
Returns
Type Description
ValueTask
Overrides
ModernStream.WriteAsync(ReadOnlyMemory<byte>, CancellationToken)

Implements

IDisposable
IAsyncDisposable
IFlushable
IValueTaskSource
IValueTaskSource<TResult>

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, params ReadOnlySpan<T>)
StreamExtensions.CopyToAsync(Stream, IBufferWriter<byte>, int, CancellationToken)
StreamExtensions.CopyToAsync(Stream, IBufferWriter<byte>, long, int, CancellationToken)
StreamExtensions.CopyToAsync(Stream, Stream, long, Memory<byte>, CancellationToken)
StreamExtensions.CopyToAsync(Stream, Stream, Memory<byte>, CancellationToken)
StreamExtensions.CopyToAsync<TConsumer>(Stream, TConsumer, long, Memory<byte>, CancellationToken)
StreamExtensions.CopyToAsync<TConsumer>(Stream, TConsumer, Memory<byte>, CancellationToken)
StreamExtensions.DecodeAsync(Stream, DecodingContext, LengthFormat, Memory<byte>, MemoryAllocator<char>?, CancellationToken)
StreamExtensions.DecodeAsync(Stream, DecodingContext, LengthFormat, Memory<char>, Memory<byte>, CancellationToken)
StreamExtensions.EncodeAsync(Stream, ReadOnlyMemory<char>, EncodingContext, LengthFormat?, Memory<byte>, CancellationToken)
StreamExtensions.FormatAsync<T>(Stream, T, EncodingContext, LengthFormat?, Memory<byte>, string?, IFormatProvider?, MemoryAllocator<char>?, CancellationToken)
StreamExtensions.FormatAsync<T>(Stream, T, LengthFormat?, Memory<byte>, string?, IFormatProvider?, CancellationToken)
StreamExtensions.ParseAsync<T>(Stream, LengthFormat, Memory<byte>, NumberStyles, IFormatProvider?, CancellationToken)
StreamExtensions.ParseAsync<T>(Stream, LengthFormat, Memory<byte>, IFormatProvider?, CancellationToken)
StreamExtensions.ParseAsync<TArg, TResult>(Stream, TArg, Func<ReadOnlySpan<char>, TArg, TResult>, DecodingContext, LengthFormat, Memory<byte>, MemoryAllocator<char>?, CancellationToken)
StreamExtensions.ReadAllAsync(Stream, int, MemoryAllocator<byte>?, CancellationToken)
StreamExtensions.ReadAsync<T>(Stream, Memory<byte>, CancellationToken)
StreamExtensions.ReadBigEndianAsync<T>(Stream, Memory<byte>, CancellationToken)
StreamExtensions.ReadBlockAsync(Stream, LengthFormat, MemoryAllocator<byte>?, CancellationToken)
StreamExtensions.ReadExactlyAsync(Stream, long, int, MemoryAllocator<byte>?, CancellationToken)
StreamExtensions.ReadLittleEndianAsync<T>(Stream, Memory<byte>, CancellationToken)
StreamExtensions.ReadUtf8(Stream, Span<byte>, IBufferWriter<char>)
StreamExtensions.ReadUtf8Async(Stream, Memory<byte>, IBufferWriter<char>, CancellationToken)
StreamExtensions.ReadUtf8Async<TArg>(Stream, Memory<byte>, Memory<char>, Func<ReadOnlyMemory<char>, TArg, CancellationToken, ValueTask>, TArg, CancellationToken)
StreamExtensions.ReadUtf8<TArg>(Stream, Span<byte>, Span<char>, ReadOnlySpanAction<char, TArg>, TArg)
StreamExtensions.Slice(Stream, long, long)
StreamExtensions.WriteAsync(Stream, ReadOnlySequence<byte>, CancellationToken)
StreamExtensions.WriteAsync(Stream, ReadOnlyMemory<byte>, LengthFormat, Memory<byte>, CancellationToken)
StreamExtensions.WriteAsync<T>(Stream, T, Memory<byte>, CancellationToken)
StreamExtensions.WriteBigEndianAsync<T>(Stream, T, Memory<byte>, CancellationToken)
StreamExtensions.WriteLittleEndianAsync<T>(Stream, T, Memory<byte>, CancellationToken)
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾