YamlProperty struct

Represents a single property for a YAML object.

Namespace: System.Text.Yaml ยท Assembly: Styml.dll

public readonly struct YamlProperty

Represents a single property for a YAML object.

PropertiesLink to this heading

KeyKindLink to this heading

Gets the kind of this property's key: YamlKeyKind.Scalar, YamlKeyKind.Alias (*name : value), or YamlKeyKind.Complex for a key that is a collection ([a, b]: value, ? {a: 1}).

public YamlKeyKind KeyKind { get; }

A collection key's YamlProperty.Name is its raw text (the key's source bytes), and text lookups (YamlProperty.NameEquals, YamlElement.TryGetProperty) match that text. Its node is YamlProperty.GetKeyElement.

NameLink to this heading

The name of this property. This allocates a new string instance for each call.

public string Name { get; }

ValueLink to this heading

The value of this property.

public YamlElement Value { get; }

MethodsLink to this heading

GetKeyElementLink to this heading

Gets this property's key as a YamlElement: a collection key's node, an alias key's anchored node, or a scalar key as a YamlValueKind.String element over its text (keys are text in the DOM), with its tag and anchor.

public YamlElement GetKeyElement();

NameEqualsLink to this heading

Compares text to the name of this property.

public bool NameEquals(string? text);

Parameters

  • text: The text to compare against.

Returns: true if the name of this property matches text, false otherwise.

Exception Condition
InvalidOperationException This value's Type is not YamlTokenType.PropertyName.

This method is functionally equal to doing an ordinal comparison of text and YamlProperty.Name, but can avoid creating the string instance.

Compares the text represented by utf8Text to the name of this property.

public bool NameEquals(ReadOnlySpan<byte> utf8Text);

Parameters

  • utf8Text: The UTF-8 encoded text to compare against.

Returns: true if the name of this property has the same UTF-8 encoding as utf8Text, false otherwise.

Exception Condition
InvalidOperationException This value's Type is not YamlTokenType.PropertyName.

This method is functionally equal to doing an ordinal comparison of utf8Text and YamlProperty.Name, but can avoid creating the string instance.

Compares text to the name of this property.

public bool NameEquals(ReadOnlySpan<char> text);

Parameters

  • text: The text to compare against.

Returns: true if the name of this property matches text, false otherwise.

Exception Condition
InvalidOperationException This value's Type is not YamlTokenType.PropertyName.

This method is functionally equal to doing an ordinal comparison of text and YamlProperty.Name, but can avoid creating the string instance.

ToStringLink to this heading

Provides a String representation of the property for debugging purposes.

public override string ToString();

Returns: A string containing the un-interpreted value of the property, beginning at the declaring open-quote and ending at the last character that is part of the value.

WriteToLink to this heading

Write the property into the provided writer as a named YAML object property.

public void WriteTo(Utf8YamlWriter writer);

Parameters

  • writer: The writer.
Exception Condition
ArgumentNullException The writer parameter is null.
ArgumentException This YamlProperty.Name's length is too large to be a YAML object property.
InvalidOperationException This YamlProperty.Value's YamlElement.ValueKind would result in an invalid YAML.
ObjectDisposedException The parent YamlDocument has been disposed.

Generated from the XML documentation of the libraryBuilt with Douze

Esc to close