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

BytesWriter 结构

表示一个基于固定内存的字节写入器,提供高性能的字节缓冲区写入功能。 实现了IBytesWriter接口。

Definition

命名空间: TouchSocket.Core
程序集: TouchSocket.Core (在 TouchSocket.Core.dll 中) 版本:4.0.0-beta.143+5fcca7a4e70968794985dc3793adc50531308be6
C#
public struct BytesWriter : IBytesWriter, 
	IBufferWriter<byte>
Inheritance
Object    ValueType    BytesWriter
Implements
IBufferWriterByte, IBytesWriter

备注

BytesWriter作为值类型实现,适用于高频使用且对性能要求较高的场景。 基于固定大小的内存块进行操作,不支持自动扩容,当空间不足时会抛出异常。

构造函数

BytesWriter 使用指定的内存块初始化BytesWriter的新实例。

属性

Position 获取或设置当前写入位置。
Span 获取已写入数据的只读跨度。
SupportsRewind 获取一个值,该值指示写入器是否支持回退操作。
TotalMemory 获取完整的内存块。
Version 获取写入器的版本号。
WrittenCount 获取已写入的字节总数。

方法

AdvanceNotifies the IBufferWriterT that count data items were written to the output SpanT or MemoryT.
EqualsIndicates whether this instance and a specified object are equal.
(继承自 ValueType。)
GetHashCodeReturns the hash code for this instance.
(继承自 ValueType。)
GetMemoryReturns a MemoryT to write to that is at least the requested size (specified by sizeHint).
GetSpanReturns a SpanT to write to that is at least the requested size (specified by sizeHint).
GetTypeGets the Type of the current instance.
(继承自 Object。)
ToStringReturns the fully qualified type name of this instance.
(继承自 ValueType。)
Write 将指定的字节跨度写入到写入器中。

扩展方法

Map 将源对象的属性映射到目标对象的属性中。
(由 Mapper 定义。)
Map 将源对象映射到目标类型的实例。
(由 Mapper 定义。)
MapTTarget 将源对象映射到指定目标类型的新实例。
(由 Mapper 定义。)
ToJsonString 转换为Json
(由 SerializeConvert 定义。)

参见