一款简单易用的基础网络通讯组件库。

ReadOnlyMemoryStream 类

表示一个基于只读内存的流,提供对ReadOnlyMemoryT的流式访问。 继承自Stream类,仅支持读取和定位操作。

Definition

命名空间: TouchSocket.Core
程序集: TouchSocket.Core (在 TouchSocket.Core.dll 中) 版本:4.0.0-beta.143+5fcca7a4e70968794985dc3793adc50531308be6
C#
public sealed class ReadOnlyMemoryStream : Stream
Inheritance
Object    MarshalByRefObject    Stream    ReadOnlyMemoryStream

备注

ReadOnlyMemoryStream为只读流实现,不支持写入操作。 提供了对内存数据的高性能流式访问,适用于需要将内存数据作为流处理的场景。 支持随机访问和定位操作。

构造函数

ReadOnlyMemoryStream 使用指定的只读内存初始化ReadOnlyMemoryStream的新实例。

属性

CanRead 获取一个值,该值指示当前流是否支持读取。
(重写 StreamCanRead)
CanSeek 获取一个值,该值指示当前流是否支持查找。
(重写 StreamCanSeek)
CanTimeoutGets a value that determines whether the current stream can time out.
(继承自 Stream。)
CanWrite 获取一个值,该值指示当前流是否支持写入。
(重写 StreamCanWrite)
Length 获取流的长度(以字节为单位)。
(重写 StreamLength)
Position 获取或设置流内的当前位置。
(重写 StreamPosition)
ReadTimeoutGets or sets a value, in milliseconds, that determines how long the stream will attempt to read before timing out.
(继承自 Stream。)
WriteTimeoutGets or sets a value, in milliseconds, that determines how long the stream will attempt to write before timing out.
(继承自 Stream。)

方法

BeginReadBegins an asynchronous read operation. (Consider using ReadAsync(Byte, Int32, Int32) instead.)
(继承自 Stream。)
BeginWriteBegins an asynchronous write operation. (Consider using WriteAsync(Byte, Int32, Int32) instead.)
(继承自 Stream。)
CloseCloses the current stream and releases any resources (such as sockets and file handles) associated with the current stream. Instead of calling this method, ensure that the stream is properly disposed.
(继承自 Stream。)
CopyTo(Stream)Reads the bytes from the current stream and writes them to another stream.
(继承自 Stream。)
CopyTo(Stream, Int32)Reads the bytes from the current stream and writes them to another stream, using a specified buffer size.
(继承自 Stream。)
CopyToAsync(Stream)Asynchronously reads the bytes from the current stream and writes them to another stream.
(继承自 Stream。)
CopyToAsync(Stream, Int32)Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size.
(继承自 Stream。)
CopyToAsync(Stream, CancellationToken)Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified cancellation token.
(继承自 Stream。)
CopyToAsync(Stream, Int32, CancellationToken)Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size and cancellation token.
(继承自 Stream。)
DisposeReleases all resources used by the Stream.
(继承自 Stream。)
DisposeAsyncAsynchronously releases the unmanaged resources used by the Stream.
(继承自 Stream。)
EndReadWaits for the pending asynchronous read to complete. (Consider using ReadAsync(Byte, Int32, Int32) instead.)
(继承自 Stream。)
EndWriteEnds an asynchronous write operation. (Consider using WriteAsync(Byte, Int32, Int32) instead.)
(继承自 Stream。)
EqualsDetermines whether the specified object is equal to the current object.
(继承自 Object。)
Flush 清除此流的缓冲区,并使得任何缓冲数据都被写入到基础设备。
(重写 StreamFlush)
FlushAsyncAsynchronously clears all buffers for this stream and causes any buffered data to be written to the underlying device.
(继承自 Stream。)
FlushAsync(CancellationToken)Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying device, and monitors cancellation requests.
(继承自 Stream。)
GetHashCodeServes as the default hash function.
(继承自 Object。)
GetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance.
(继承自 MarshalByRefObject。)
已过时
GetTypeGets the Type of the current instance.
(继承自 Object。)
InitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance.
(继承自 MarshalByRefObject。)
已过时
Read(SpanByte)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.
(继承自 Stream。)
Read(Byte, Int32, Int32) 从当前流读取字节序列,并将流内的位置提升读取的字节数。
(重写 StreamRead(Byte, Int32, Int32))
ReadAsync(MemoryByte, CancellationToken)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.
(继承自 Stream。)
ReadAsync(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.
(继承自 Stream。)
ReadAsync(Byte, Int32, Int32, CancellationToken)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.
(继承自 Stream。)
ReadByteReads 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.
(继承自 Stream。)
Seek 设置当前流内的位置。
(重写 StreamSeek(Int64, SeekOrigin))
SetLength 设置当前流的长度。
(重写 StreamSetLength(Int64))
ToStringReturns a string that represents the current object.
(继承自 Object。)
Write(ReadOnlySpanByte)When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
(继承自 Stream。)
Write(Byte, Int32, Int32) 将字节序列写入当前流,并将此流中的当前位置提升写入的字节数。
(重写 StreamWrite(Byte, Int32, Int32))
WriteAsync(ReadOnlyMemoryByte, CancellationToken)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.
(继承自 Stream。)
WriteAsync(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.
(继承自 Stream。)
WriteAsync(Byte, Int32, Int32, CancellationToken)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.
(继承自 Stream。)
WriteByteWrites a byte to the current position in the stream and advances the position within the stream by one byte.
(继承自 Stream。)

扩展方法

Map 将源对象的属性映射到目标对象的属性中。
(由 Mapper 定义。)
Map 将源对象映射到目标类型的实例。
(由 Mapper 定义。)
MapTTarget 将源对象映射到指定目标类型的新实例。
(由 Mapper 定义。)
ReadAllToByteArray 读取流中的所有字节并返回字节数组。
(由 SystemExtension 定义。)
ToJsonString 转换为Json
(由 SerializeConvert 定义。)

参见