Table of Contents

Class BinaryStreamWriter

Namespace
AsmResolver.IO
Assembly
AsmResolver.dll

Provides methods for writing data to an output stream.

public sealed class BinaryStreamWriter
Inheritance
BinaryStreamWriter
Inherited Members

Constructors

BinaryStreamWriter(Stream)

Creates a new binary stream writer using the provided output stream.

public BinaryStreamWriter(Stream stream)

Parameters

stream Stream

The stream to write to.

Properties

BaseStream

Gets the stream this writer writes to.

public Stream BaseStream { get; }

Property Value

Stream

Length

Gets or sets the current length of the stream.

public uint Length { get; }

Property Value

uint

Offset

Gets or sets the current position of the

public ulong Offset { get; set; }

Property Value

ulong

Methods

Align(uint)

Aligns the writer to a specified boundary.

public void Align(uint align)

Parameters

align uint

The boundary to use.

AlignRelative(uint, ulong)

Aligns the writer to a specified boundary, relative to the provided start offset..

public void AlignRelative(uint align, ulong startOffset)

Parameters

align uint

The boundary to use.

startOffset ulong

The starting offset to consider the alignment boundaries from.

Write7BitEncodedInt32(int)

Writes a single 7-bit encoded 32-bit integer to the output stream.

public void Write7BitEncodedInt32(int value)

Parameters

value int

The value to write.

WriteAsciiString(string)

Writes an ASCII string to the stream.

public void WriteAsciiString(string value)

Parameters

value string

The string to write.

WriteBinaryFormatterString(string)

Writes a serialized string using the UTF-8 encoding that is prefixed by a 7-bit encoded length header.

public void WriteBinaryFormatterString(string value)

Parameters

value string

The string to write.

WriteBinaryFormatterString(string, Encoding)

Writes a serialized string that is prefixed by a 7-bit encoded length header.

public void WriteBinaryFormatterString(string value, Encoding encoding)

Parameters

value string

The string to write.

encoding Encoding

The encoding to use.

WriteByte(byte)

Writes a single byte to the stream.

public void WriteByte(byte value)

Parameters

value byte

The byte to write.

WriteBytes(byte[])

Writes a buffer of data to the stream.

public void WriteBytes(byte[] buffer)

Parameters

buffer byte[]

The data to write.

WriteBytes(byte[], int, int)

Writes a buffer of data to the stream.

public void WriteBytes(byte[] buffer, int startIndex, int count)

Parameters

buffer byte[]

The buffer to write to the stream.

startIndex int

The index to start reading from the buffer.

count int

The amount of bytes of the buffer to write.

WriteBytes(ReadOnlySpan<byte>)

Writes a buffer of data to the stream.

public void WriteBytes(ReadOnlySpan<byte> buffer)

Parameters

buffer ReadOnlySpan<byte>

The buffer to write to the stream.

WriteCompressedInt32(int)

Compresses and writes a signed integer to the stream.

public void WriteCompressedInt32(int value)

Parameters

value int

The value to write.

WriteCompressedUInt32(uint)

Compresses and writes an unsigned integer to the stream.

public void WriteCompressedUInt32(uint value)

Parameters

value uint

The value to write.

WriteDecimal(decimal)

Writes a 128-bit decimal value to the stream.

public void WriteDecimal(decimal value)

Parameters

value decimal

The 128-bit decimal value to write.

WriteDouble(double)

Writes a 64-bit floating point number to the stream.

public void WriteDouble(double value)

Parameters

value double

The 64-bit floating point number to write.

WriteIndex(uint, IndexSize)

Writes a single index to the output stream.

public void WriteIndex(uint value, IndexSize size)

Parameters

value uint

The index to write.

size IndexSize

Exceptions

ArgumentOutOfRangeException

WriteInt16(short)

Writes a signed 16-bit integer to the stream.

public void WriteInt16(short value)

Parameters

value short

The signed 16-bit integer to write.

WriteInt32(int)

Writes a signed 32-bit integer to the stream.

public void WriteInt32(int value)

Parameters

value int

The signed 32-bit integer to write.

WriteInt64(long)

Writes a signed 64-bit integer to the stream.

public void WriteInt64(long value)

Parameters

value long

The signed 64-bit integer to write.

WriteNativeInt(ulong, bool)

Writes either a 32-bit or a 64-bit number to the output stream.

public void WriteNativeInt(ulong value, bool is32Bit)

Parameters

value ulong

The value to write.

is32Bit bool

Indicates the integer to be written is 32-bit or 64-bit.

WriteSByte(sbyte)

Writes an signed byte to the stream.

public void WriteSByte(sbyte value)

Parameters

value sbyte

The signed byte to write.

WriteSerString(Utf8String?)

Writes an UTF8 string to the stream.

public void WriteSerString(Utf8String? value)

Parameters

value Utf8String

The string to write.

WriteSerString(string?)

Writes an UTF8 string to the stream.

public void WriteSerString(string? value)

Parameters

value string

The string to write.

WriteSingle(float)

Writes a 32-bit floating point number to the stream.

public void WriteSingle(float value)

Parameters

value float

The 32-bit floating point number to write.

WriteUInt16(ushort)

Writes an unsigned 16-bit integer to the stream.

public void WriteUInt16(ushort value)

Parameters

value ushort

The unsigned 16-bit integer to write.

WriteUInt32(uint)

Writes an unsigned 32-bit integer to the stream.

public void WriteUInt32(uint value)

Parameters

value uint

The unsigned 32-bit integer to write.

WriteUInt64(ulong)

Writes an unsigned 64-bit integer to the stream.

public void WriteUInt64(ulong value)

Parameters

value ulong

The unsigned 64-bit integer to write.

WriteZeroes(int)

Writes a specified number of zero bytes to the stream.

public void WriteZeroes(int count)

Parameters

count int

The number of zeroes to write.