YamlScalar
OfficeIMO.Yaml
A scalar node: plain, quoted or block text. A loaded scalar keeps its source spelling (TRUE, 0x1F, ~) and decodes its value once, on first use. An omitted node (key: with no value) is an empty plain scalar.
Inheritance
- YamlNode
- YamlScalar
Remarks
Setting a value equal to the current one under the document's schema keeps the source text, so setting true on TRUE changes nothing. A different value keeps the scalar's style when that style can represent it, and otherwise takes the most conservative style that does.
Usage
Explore 7 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 7
- Method YamlAlias.AsScalar
- Method YamlMapping.AsScalar
- Method YamlMapping.RenameKey
- Method YamlNode.AsScalar
- Method YamlScalar.AsScalar
- Method YamlScalar.SetValue
- Method YamlSequence.AsScalar
Constructors
public YamlScalar(string? value) #Creates a string scalar, or a null scalar (null) when value is null. The style is chosen when the scalar joins a document: plain when no YAML 1.2 core or YAML 1.1 reader could read the text as anything but a string, otherwise following the quoting its siblings use.
Parameters
- value string?
public YamlScalar(string value, YamlStyle style) #Creates a string scalar with a requested style. When it joins a document, a style that cannot represent the value at its position gives way to the most conservative one that can. A plain style is kept even when the text reads as another type, so new YamlScalar("on", YamlStyle.Plain) writes on.
Parameters
- value string
- style OfficeIMO.Yaml.YamlStyle
Exceptions
ArgumentOutOfRangeException– style is not a scalar style.
public YamlScalar(double value) #Creates a floating-point scalar spelled so YAML 1.2 and YAML 1.1 readers read the same float (1.0, .inf).
Parameters
- value double
Methods
public YamlScalar SetValue(string? value, YamlStyle style = None) #Sets a string value, or null with null. The style is kept when it can represent the value at this position; otherwise, or for YamlStyle.None, it is chosen as for a new scalar. An equal value keeps the source text.
Parameters
- value string?
- style OfficeIMO.Yaml.YamlStyle = None
public YamlScalar SetValue(long value) #Sets an integer value, keeping the source text when it already equals it (0x1F for 31).
Parameters
- value long
public YamlScalar SetValue(double value) #Sets a floating-point value, keeping the source text when it already equals it.
Parameters
- value double
public YamlScalar SetValue(bool value) #Sets a boolean value, keeping the source text when it already equals it (TRUE, or yes under YAML 1.1).
Parameters
- value bool
Inherited Methods
public YamlNode SetAnchor(string? name) #Parameters
- name string?
Returns
YamlNodepublic YamlNode SetComment(string? text) #Parameters
- text string?
Returns
YamlNodepublic YamlNode SetCommentBefore(string? text) #Parameters
- text string?
Returns
YamlNodepublic YamlNode SetSpaceBefore(bool value) #Parameters
- value bool
Returns
YamlNodeProperties
public string RawText { get; } #Gets the scalar's raw text: for a loaded scalar the content between the quotes with escapes intact, or a block scalar's content lines with their indentation, without the header; for a scalar set by editing, the text saving writes for it, with the same parts removed. Use YamlNode.AsString for the decoded value.
public YamlScalarKind Kind { get; } #Gets what the scalar resolves to under its document's schema: null, boolean, integer, float, string, timestamp, a merge key or YAML 1.1 value key, or YamlScalarKind.Custom for a tag no schema resolves. Use it to pick the YamlNode.GetValue type without trying each one.