Table of Contents

Class YamlConverterFactory

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

Provides a factory based way to create and wrap an YamlConverter implementation.

public static class YamlConverterFactory
Inheritance
YamlConverterFactory

Methods

Create(Func<Type, bool>, Action<IEmitter, object, YamlFormatter>, Func<IParser, Type, YamlFormatter, object>)

Creates a dynamic instance of an YamlConverter implementation wrapping Codebelt.Extensions.YamlDotNet.Converters.YamlConverter.WriteYamlCore(YamlDotNet.Core.IEmitter, object, YamlDotNet.Serialization.ObjectSerializer) through writer and ReadYamlCore(IParser, Type, ObjectDeserializer) through reader.

public static YamlConverter Create(Func<Type, bool> predicate, Action<IEmitter, object, YamlFormatter> writer = null, Func<IParser, Type, YamlFormatter, object> reader = null)

Parameters

predicate Func<Type, bool>

The function delegate that validates if the given Type can be converted to or from YAML.

writer Action<IEmitter, object, YamlFormatter>

The delegate that converts an object to its YAML representation.

reader Func<IParser, Type, YamlFormatter, object>

The delegate that generates an object from its YAML representation.

Returns

YamlConverter

An YamlConverter implementation of an object.

Create(Type, Action<IEmitter, object, YamlFormatter>, Func<IParser, Type, YamlFormatter, object>)

Creates a dynamic instance of an YamlConverter implementation wrapping Codebelt.Extensions.YamlDotNet.Converters.YamlConverter.WriteYamlCore(YamlDotNet.Core.IEmitter, object, YamlDotNet.Serialization.ObjectSerializer) through writer and ReadYamlCore(IParser, Type, ObjectDeserializer) through reader.

public static YamlConverter Create(Type typeToConvert, Action<IEmitter, object, YamlFormatter> writer = null, Func<IParser, Type, YamlFormatter, object> reader = null)

Parameters

typeToConvert Type

The type to convert.

writer Action<IEmitter, object, YamlFormatter>

The delegate that converts an object to its YAML representation.

reader Func<IParser, Type, YamlFormatter, object>

The delegate that generates an object from its YAML representation.

Returns

YamlConverter

An YamlConverter implementation of an object.

Create<T>(Action<IEmitter, T, YamlFormatter>, Func<IParser, Type, YamlFormatter, T>)

Creates a dynamic instance of an YamlConverter<T> implementation wrapping WriteYaml(IEmitter, T) through writer and ReadYaml(IParser, Type) through reader.

public static YamlConverter Create<T>(Action<IEmitter, T, YamlFormatter> writer = null, Func<IParser, Type, YamlFormatter, T> reader = null)

Parameters

writer Action<IEmitter, T, YamlFormatter>

The delegate that converts T to its YAML representation.

reader Func<IParser, Type, YamlFormatter, T>

The delegate that generates T from its YAML representation.

Returns

YamlConverter

An YamlConverter implementation of T.

Type Parameters

T

The type to implement an YamlConverter for.

Create<T>(Func<Type, bool>, Action<IEmitter, T, YamlFormatter>, Func<IParser, Type, YamlFormatter, T>)

Creates a dynamic instance of an YamlConverter<T> implementation wrapping WriteYaml(IEmitter, T) through writer and ReadYaml(IParser, Type) through reader.

public static YamlConverter Create<T>(Func<Type, bool> predicate, Action<IEmitter, T, YamlFormatter> writer = null, Func<IParser, Type, YamlFormatter, T> reader = null)

Parameters

predicate Func<Type, bool>

The function delegate that validates if the given Type can be converted to or from YAML.

writer Action<IEmitter, T, YamlFormatter>

The delegate that converts T to its YAML representation.

reader Func<IParser, Type, YamlFormatter, T>

The delegate that generates T from its YAML representation.

Returns

YamlConverter

An YamlConverter implementation of T.

Type Parameters

T

The type to implement an YamlConverter for.