Table of Contents

YamlDocument Class

Definition

Namespace
Bodu.Text.Yaml.Document
Assembly
Bodu.Text.Yaml.dll
Package
Bodu.Text.Yaml 1.0.0
Source
YamlDocument.Stream.cs

Represents a parsed, read-only YAML document as an immutable tree of YamlElement views over a flat, index-linked node store, in the manner of System.Text.Json.JsonDocument.

public sealed class YamlDocument : IDisposable
Inheritance
YamlDocument
Implements
Inherited Members
Extension Methods

Remarks

The document materializes a single YAML document from its source. Element views are lightweight structs that remain valid until the document is disposed. The type is not thread-safe for concurrent disposal with reads.

Properties

RootElement

Gets the root element of the document.

public YamlElement RootElement { get; }

Property Value

YamlElement

The element view onto the document root.

Methods

Dispose()

Releases the resources held by the document and invalidates its element views.

public void Dispose()

Parse(ReadOnlySpan<byte>)

Parses a YAML document from UTF-8 source.

public static YamlDocument Parse(ReadOnlySpan<byte> utf8Yaml)

Parameters

utf8Yaml ReadOnlySpan<byte>

The UTF-8 encoded YAML source.

Returns

YamlDocument

The parsed document.

Exceptions

YamlFormatException

The source is not valid YAML.

Parse(ReadOnlySpan<byte>, YamlDocumentOptions)

Parses a YAML document from UTF-8 source using the specified options.

public static YamlDocument Parse(ReadOnlySpan<byte> utf8Yaml, YamlDocumentOptions options)

Parameters

utf8Yaml ReadOnlySpan<byte>

The UTF-8 encoded YAML source.

options YamlDocumentOptions

The parsing options.

Returns

YamlDocument

The parsed document.

Exceptions

YamlFormatException

The source is not valid YAML.

Parse(string)

Parses a YAML document from a string.

public static YamlDocument Parse(string yaml)

Parameters

yaml string

The YAML source text.

Returns

YamlDocument

The parsed document.

Exceptions

ArgumentNullException

yaml is null.

YamlFormatException

The source is not valid YAML.

Parse(string, YamlDocumentOptions)

Parses a YAML document from a string using the specified options.

public static YamlDocument Parse(string yaml, YamlDocumentOptions options)

Parameters

yaml string

The YAML source text.

options YamlDocumentOptions

The parsing options.

Returns

YamlDocument

The parsed document.

Exceptions

ArgumentNullException

yaml is null.

YamlFormatException

The source is not valid YAML.

ParseAllDocuments(ReadOnlySpan<byte>)

Parses every document in a multi-document YAML stream from UTF-8 source.

public static IReadOnlyList<YamlDocument> ParseAllDocuments(ReadOnlySpan<byte> utf8Yaml)

Parameters

utf8Yaml ReadOnlySpan<byte>

The UTF-8 encoded YAML stream.

Returns

IReadOnlyList<YamlDocument>

The parsed documents, in stream order.

Exceptions

YamlFormatException

The source is not valid YAML.

ParseAllDocuments(ReadOnlySpan<byte>, YamlDocumentOptions)

Parses every document in a multi-document YAML stream from UTF-8 source using the specified options.

public static IReadOnlyList<YamlDocument> ParseAllDocuments(ReadOnlySpan<byte> utf8Yaml, YamlDocumentOptions options)

Parameters

utf8Yaml ReadOnlySpan<byte>

The UTF-8 encoded YAML stream.

options YamlDocumentOptions

The parsing options.

Returns

IReadOnlyList<YamlDocument>

The parsed documents, in stream order.

Exceptions

YamlFormatException

The source is not valid YAML.

ParseAllDocuments(string)

Parses every document in a multi-document YAML stream from a string.

public static IReadOnlyList<YamlDocument> ParseAllDocuments(string yaml)

Parameters

yaml string

The YAML stream text.

Returns

IReadOnlyList<YamlDocument>

The parsed documents, in stream order.

Exceptions

ArgumentNullException

yaml is null.

YamlFormatException

The source is not valid YAML.

ParseAllDocuments(string, YamlDocumentOptions)

Parses every document in a multi-document YAML stream from a string using the specified options.

public static IReadOnlyList<YamlDocument> ParseAllDocuments(string yaml, YamlDocumentOptions options)

Parameters

yaml string

The YAML stream text.

options YamlDocumentOptions

The parsing options.

Returns

IReadOnlyList<YamlDocument>

The parsed documents, in stream order.

Exceptions

ArgumentNullException

yaml is null.

YamlFormatException

The source is not valid YAML.

Applies to

ProductVersions
.NET8, 10