Utf8IniWriter Struct
Definition
Provides a forward-only writer that emits INI text as UTF-8 bytes to an IBufferWriter<T> or a
Stream. The writer is a ref struct.
public ref struct Utf8IniWriter
- Inherited Members
Remarks
INI is line-oriented, so the writer emits progressively: WriteSectionHeader(string) produces a
[name] line, WritePropertyName(string) followed by WriteString(string) produces
one key=value line, and WriteComment(string) produces one comment line.
Constructors
Utf8IniWriter(IBufferWriter<byte>)
Initializes a new instance of the Utf8IniWriter struct that writes to the supplied buffer.
public Utf8IniWriter(IBufferWriter<byte> output)
Parameters
outputIBufferWriter<byte>The destination buffer writer.
Exceptions
- ArgumentNullException
Thrown when
outputis null.
Utf8IniWriter(IBufferWriter<byte>, IniWriterOptions)
Initializes a new instance of the Utf8IniWriter struct that writes to the supplied buffer using the supplied options.
public Utf8IniWriter(IBufferWriter<byte> output, IniWriterOptions options)
Parameters
outputIBufferWriter<byte>The destination buffer writer.
optionsIniWriterOptionsThe writer options.
Exceptions
- ArgumentNullException
Thrown when
outputis null.
Utf8IniWriter(Stream)
Initializes a new instance of the Utf8IniWriter struct that writes to the supplied stream.
public Utf8IniWriter(Stream stream)
Parameters
streamStreamThe destination stream.
Exceptions
- ArgumentNullException
Thrown when
streamis null.
Utf8IniWriter(Stream, IniWriterOptions)
Initializes a new instance of the Utf8IniWriter struct that writes to the supplied stream using the supplied options.
public Utf8IniWriter(Stream stream, IniWriterOptions options)
Parameters
streamStreamThe destination stream.
optionsIniWriterOptionsThe writer options.
Exceptions
- ArgumentNullException
Thrown when
streamis null.
Properties
BytesCommitted
Gets the number of bytes flushed to the destination.
public readonly long BytesCommitted { get; }
Property Value
- long
The committed byte count.
BytesPending
Gets the number of bytes written but not yet flushed to the destination.
public readonly long BytesPending { get; }
Property Value
- long
The pending byte count; always zero in direct buffer-writer mode.
Methods
Dispose()
Flushes any buffered bytes and releases the writer.
public void Dispose()
Flush()
Flushes any buffered bytes to the destination stream. This method is a no-op in direct buffer-writer mode.
public void Flush()
WriteComment(string)
Writes a comment line prefixed with the configured comment character, followed by a line feed.
public void WriteComment(string text)
Parameters
textstringThe comment text, without the leading prefix.
Exceptions
- ArgumentNullException
Thrown when
textis null.
WritePropertyName(string)
Writes a key name, followed by the = assignment. Call WriteString(string) next to write
the value.
public void WritePropertyName(string name)
Parameters
namestringThe key name.
Exceptions
- ArgumentNullException
Thrown when
nameis null.
WriteSectionHeader(string)
Writes a section header line ([name]).
public void WriteSectionHeader(string name)
Parameters
namestringThe section name.
Exceptions
- ArgumentNullException
Thrown when
nameis null.
WriteString(string)
Writes a string value, followed by a line feed.
public void WriteString(string value)
Parameters
valuestringThe value to write.
Exceptions
- ArgumentNullException
Thrown when
valueis null.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |