YamlDocument Class
A read-only representation of a UTF-8 YAML stream: one row per node in a pooled array over the input bytes. Scalars are decoded only when asked for, and every node keeps the location of its text in the input.
public sealed class YamlDocument : IDisposableRemarks
Dispose the document to return its buffers to the pool. Its nodes must not be used after that.
- Implements
Properties
| Name | Description |
|---|---|
| DocumentCount | Gets the number of documents of the stream. |
| Root | Gets the root node of the first document. |
| Utf8Text | Gets the UTF-8 input of the document. |
DocumentCount
YamlDocument.csRoot
YamlDocument.csGets the root node of the first document.
public YamlElement Root { get; }Utf8Text
YamlDocument.csMethods
| Name | Description |
|---|---|
| Dispose() | Returns the buffers of the document to the pool. |
| GetDocumentRoot(int) | Gets the root node of a document of the stream. |
| Parse(Stream, Utf8YamlReaderOptions) | Reads a UTF-8 YAML stream to its end and parses it. |
| Parse(ReadOnlyMemory<byte>, Utf8YamlReaderOptions) | Parses a UTF-8 YAML stream. The document keeps a reference to utf8Yaml, which must not change while it is used. |
| Parse(string, Utf8YamlReaderOptions) | Parses a YAML stream. |
| WriteTo(Utf8YamlWriter) | Writes every document of the stream, with its %TAG directives, each one after the first with a --- marker. |
Dispose()
YamlDocument.csReturns the buffers of the document to the pool.
public void Dispose()GetDocumentRoot(int)
YamlDocument.csGets the root node of a document of the stream.
public YamlElement GetDocumentRoot(int index)Parse overloads
Parse(Stream, Utf8YamlReaderOptions)
YamlDocument.csReads a UTF-8 YAML stream to its end and parses it.
public static YamlDocument Parse(Stream utf8Yaml, Utf8YamlReaderOptions options = default)Parameters
utf8YamlStreamoptionsUtf8YamlReaderOptions
Returns
Exceptions
ArgumentNullExceptionutf8Yamlisnull.YamlException- The input is not valid YAML.
Parse(ReadOnlyMemory<byte>, Utf8YamlReaderOptions)
YamlDocument.csParses a UTF-8 YAML stream. The document keeps a reference to utf8Yaml, which must not change while it is used.
public static YamlDocument Parse(ReadOnlyMemory<byte> utf8Yaml, Utf8YamlReaderOptions options = default)Parameters
utf8YamlReadOnlyMemory<byte>optionsUtf8YamlReaderOptions
Returns
Exceptions
YamlException- The input is not valid YAML.
Parse(string, Utf8YamlReaderOptions)
YamlDocument.csParses a YAML stream.
public static YamlDocument Parse(string yaml, Utf8YamlReaderOptions options = default)Parameters
yamlstringoptionsUtf8YamlReaderOptions
Returns
Exceptions
ArgumentNullExceptionyamlisnull.YamlException- The input is not valid YAML.
WriteTo(Utf8YamlWriter)
YamlDocument.csWrites every document of the stream, with its %TAG directives, each one after the first with a --- marker.
public void WriteTo(Utf8YamlWriter writer)Parameters
writerUtf8YamlWriter- The destination.
Exceptions
ArgumentNullExceptionwriterisnull.
Remarks
See YamlElement.WriteTo. The tags are written with the handles of the directives.