Table of Contents

Class YamlSerializerOptions

Namespace
Codebelt.Extensions.YamlDotNet
Assembly
Codebelt.Extensions.YamlDotNet.dll

Configuration options for YamlDotNet.Serialization.SerializerBuilder and YamlDotNet.Serialization.DeserializerBuilder.

public class YamlSerializerOptions : EncodingOptions, IEncodingOptions, IValidatableParameterObject, IParameterObject
Inheritance
Object
YamlSerializerOptions
Implements
Inherited Members

Constructors

YamlSerializerOptions()

Initializes a new instance of the YamlSerializerOptions class.

public YamlSerializerOptions()

Remarks

The following table shows the initial property values for an instance of YamlSerializerOptions.

PropertyInitial Value
ConvertersSystem.Collections.Generic.List`1
ReflectionRulesnew MemberReflection(true, true);
WhiteSpaceIndentation2
UseAliasesfalse
NamingConventionNullNamingConvention.Instance
EnumNamingConventionNullNamingConvention.Instance
MaximumRecursion25
NewLineEnvironment.NewLine
FormatterYamlFormatter.Default
FormatProviderCultureInfo.InvariantCulture
IndentSequencestrue
TextWidthint.MaxValue
ValuesHandlingDefaultValuesHandling.Preserve
EnsureRoundtripfalse

Properties

Converters

Gets a YamlConverter collection that will be used during serialization.

public IList<YamlConverter> Converters { get; set; }

Property Value

IList<YamlConverter>

The converters that will be used during serialization.

EnsureRoundtrip

Gets or sets a value that will force the emission of tags and emit only properties with setters. The default value is false.

public bool EnsureRoundtrip { get; set; }

Property Value

Boolean

true to force the emission of tags and emit only properties with setters; otherwise, false.

EnumNamingConvention

Gets or sets the YamlDotNet.Serialization.INamingConvention used when handling enum values. The default value is YamlDotNet.Serialization.NamingConventions.NullNamingConvention.Instance (unaltered).

public INamingConvention EnumNamingConvention { get; set; }

Property Value

INamingConvention

The YamlDotNet.Serialization.INamingConvention used when handling enum values.

FormatProvider

Gets or sets the culture-specific formatting information used when writing YAML. The default is System.Globalization.CultureInfo.InvariantCulture.

public CultureInfo FormatProvider { get; set; }

Property Value

CultureInfo

An System.IFormatProvider that contains the culture-specific formatting information.

Formatter

Gets or sets formatting options for the generated YAML. Defaults to YamlDotNet.Serialization.YamlFormatter.Default.

public YamlFormatter Formatter { get; set; }

Property Value

YamlFormatter

The formatting options for the generated YAML.

IndentSequences

Gets or sets a value indicating whether to indent sequences/arrays in the generated YAML. The default value is true.

public bool IndentSequences { get; set; }

Property Value

Boolean

true to indent sequences/arrays in the generated YAML; otherwise, false.

IsCanonical

Gets or sets a value indicating whether the output is in a canonical form.

public bool IsCanonical { get; set; }

Property Value

Boolean

true if the output is in a canonical form; otherwise, false.

MaximumRecursion

Gets or sets the maximum recursion that is allowed while traversing the object graph. The default value is 50.

public int MaximumRecursion { get; set; }

Property Value

Int32

The maximum recursion that is allowed while traversing the object graph.

NamingConvention

Gets or sets the YamlDotNet.Serialization.INamingConvention used to convert a property's name on an object to another format. The default value is YamlDotNet.Serialization.NamingConventions.NullNamingConvention.Instance (unaltered).

public INamingConvention NamingConvention { get; set; }

Property Value

INamingConvention

The YamlDotNet.Serialization.INamingConvention used to convert a property's name on an object to another format.

NewLine

Gets or sets the new line character to use when serializing to YAML. Default is System.Environment.NewLine.

public string NewLine { get; set; }

Property Value

String

The new line character to use when serializing to YAML.

ReflectionRules

Gets or sets the binding constraints for reflection based member searching.

public MemberReflection ReflectionRules { get; set; }

Property Value

MemberReflection

The binding constraints for reflection based member searching.

Exceptions

System.ArgumentNullException

value cannot be null.

ScalarStyle

Gets or sets the default quoting style for scalar values. The default value is YamlDotNet.Core.ScalarStyle.Any.

public ScalarStyle ScalarStyle { get; set; }

Property Value

ScalarStyle

The default quoting style for scalar values.

TextWidth

Gets or sets the preferred width of text in the generated YAML.

public int TextWidth { get; set; }

Property Value

Int32

The preferred width of text in the generated YAML.

UseAliases

Gets or sets a value indicating whether to allow use of aliases in the generated YAML. The default value is false.

public bool UseAliases { get; set; }

Property Value

Boolean

true to allow use of aliases in the generated YAML; otherwise, false.

ValuesHandling

Gets or sets how properties with default and null values should be handled. The default value is YamlDotNet.Serialization.DefaultValuesHandling.Preserve.

public DefaultValuesHandling ValuesHandling { get; set; }

Property Value

DefaultValuesHandling

How properties with default and null values should be handled. The default value is YamlDotNet.Serialization.DefaultValuesHandling.Preserve.

WhiteSpaceIndentation

Gets or sets the white space indentation.

public int WhiteSpaceIndentation { get; set; }

Property Value

Int32

The white space indentation.

Methods

ValidateOptions()

Determines whether the public read-write properties of this instance are in a valid state.

public void ValidateOptions()

Remarks

This method is expected to throw exceptions when one or more conditions fails to be in a valid state.

Exceptions

System.InvalidOperationException

Converters cannot be null - or -, ReflectionRules cannot be null.