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
predicateFunc<Type, bool>The function delegate that validates if the given Type can be converted to or from YAML.
writerAction<IEmitter, object, YamlFormatter>The delegate that converts an object to its YAML representation.
readerFunc<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
typeToConvertTypeThe type to convert.
writerAction<IEmitter, object, YamlFormatter>The delegate that converts an object to its YAML representation.
readerFunc<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
writerAction<IEmitter, T, YamlFormatter>The delegate that converts
Tto its YAML representation.readerFunc<IParser, Type, YamlFormatter, T>The delegate that generates
Tfrom its YAML representation.
Returns
- YamlConverter
An YamlConverter implementation of
T.
Type Parameters
TThe 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
predicateFunc<Type, bool>The function delegate that validates if the given Type can be converted to or from YAML.
writerAction<IEmitter, T, YamlFormatter>The delegate that converts
Tto its YAML representation.readerFunc<IParser, Type, YamlFormatter, T>The delegate that generates
Tfrom its YAML representation.
Returns
- YamlConverter
An YamlConverter implementation of
T.
Type Parameters
TThe type to implement an YamlConverter for.