Class YamlFormatter
- Namespace
- Codebelt.Extensions.YamlDotNet.Formatters
- Assembly
- Codebelt.Extensions.YamlDotNet.dll
Serializes and deserializes an object, in YAML format.
public class YamlFormatter : StreamFormatter<YamlFormatterOptions>, IConfigurable<YamlFormatterOptions>
- Inheritance
-
YamlFormatter
- Implements
- Inherited Members
Constructors
YamlFormatter()
Initializes a new instance of the YamlFormatter class.
public YamlFormatter()
YamlFormatter(YamlFormatterOptions)
Initializes a new instance of the YamlFormatter class.
public YamlFormatter(YamlFormatterOptions options)
Parameters
optionsYamlFormatterOptionsThe configured YamlFormatterOptions.
YamlFormatter(Action<YamlFormatterOptions>)
Initializes a new instance of the YamlFormatter class.
public YamlFormatter(Action<YamlFormatterOptions> setup)
Parameters
setupAction<YamlFormatterOptions>The YamlFormatterOptions which need to be configured.
Methods
Deserialize(Stream, Action<IDeserializer, Parser>)
Deserializes the specified value using delegate deserializerFactory.
public void Deserialize(Stream value, Action<IDeserializer, Parser> deserializerFactory)
Parameters
valueStreamThe object from which to deserialize the object graph.
deserializerFactoryAction<IDeserializer, Parser>The delegate that performs the deserialization.
Exceptions
- ArgumentNullException
valueis null -or-deserializerFactoryis null.
Deserialize(Stream, Type)
Deserializes the specified value into an object of objectType.
public override object Deserialize(Stream value, Type objectType)
Parameters
valueStreamThe object from which to deserialize the object graph.
objectTypeTypeThe type of the deserialized object.
Returns
- object
An object of
objectType.
Exceptions
- ArgumentNullException
valueis null -or-objectTypeis null.
DeserializeObject(Stream, Action<IDeserializer, Parser>, YamlFormatterOptions)
Deserializes the specified value using delegate deserializerFactory.
public static void DeserializeObject(Stream value, Action<IDeserializer, Parser> deserializerFactory, YamlFormatterOptions options)
Parameters
valueStreamThe string from which to deserialize the object graph.
deserializerFactoryAction<IDeserializer, Parser>The delegate that performs the deserialization.
optionsYamlFormatterOptionsThe configured YamlFormatterOptions.
DeserializeObject(Stream, Action<IDeserializer, Parser>, Action<YamlFormatterOptions>)
Deserializes the specified value using delegate deserializerFactory.
public static void DeserializeObject(Stream value, Action<IDeserializer, Parser> deserializerFactory, Action<YamlFormatterOptions> setup = null)
Parameters
valueStreamThe string from which to deserialize the object graph.
deserializerFactoryAction<IDeserializer, Parser>The delegate that performs the deserialization.
setupAction<YamlFormatterOptions>The YamlFormatterOptions which may be configured.
Serialize(object, Type)
Serializes the specified source to an object of Stream.
public override Stream Serialize(object source, Type objectType)
Parameters
sourceobjectThe object to serialize to YAML format.
objectTypeTypeThe type of the object to serialize.
Returns
- Stream
A stream of the serialized
source.
Exceptions
- ArgumentNullException
sourceis null -or-objectTypeis null.