YamlScalarStylePreferences Class
Provides high-level preferences for scalar style emission.
public sealed class YamlScalarStylePreferencesConstructors
| Name | Description |
|---|---|
| YamlScalarStylePreferences() |
YamlScalarStylePreferences()
YamlScalarStylePreferences.cspublic YamlScalarStylePreferences()No documentation is available.
Properties
| Name | Description |
|---|---|
| PreferPlainStyle | Gets or sets a value indicating whether plain style should be preferred when possible. |
| PreferQuotedForAmbiguousScalars | Gets or sets a value indicating whether quoted style should be preferred for ambiguous scalars. |
| StringStyle | Gets or sets the style used to emit string values. |
PreferPlainStyle
YamlScalarStylePreferences.csPreferQuotedForAmbiguousScalars
YamlScalarStylePreferences.csStringStyle
YamlScalarStylePreferences.csGets or sets the style used to emit string values.
public ScalarStyle StringStyle { get; init; }Property value
Exceptions
ArgumentOutOfRangeException- Value is not a defined
ScalarStyle.
Remarks
The default is ScalarStyle.Any, which lets the writer pick between the plain and the double-quoted style. Any other value asks for that style, for example ScalarStyle.Literal to emit a block scalar (|):
script: |-
echo one
echo twoThe requested style is used only when the value round-trips through it. A literal or folded scalar cannot represent an empty value, a carriage return, a control character, or a line that ends with a blank, and no block scalar can be written inside a flow collection. When the style does not fit, the value is written using the automatic style instead.
This applies to string values. Mapping keys and non-string scalars such as numbers, booleans, and dates keep their own representation.