Class HumlConverter<T>

Namespace
Huml.Net.Serialization
Assembly
Huml.Net.dll

Typed HUML converter for T. Override Read(HumlNode) and Write(HumlWriterContext, T) to control how T is deserialised and serialised.

public abstract class HumlConverter<T> : HumlConverter

Type Parameters

T

The CLR type this converter handles.

Inheritance
HumlConverter<T>
Inherited Members

Remarks

Instances are cached and shared across threads — converters must be stateless. Do not call AppendSerializedValue(object?) with a value of type T inside Write(HumlWriterContext, T); this creates infinite recursion. Use AppendRaw(string) for custom HUML output instead.

Methods

CanConvert(Type)

Returns true when this converter can handle typeToConvert.

public override bool CanConvert(Type typeToConvert)

Parameters

typeToConvert Type

The CLR type to evaluate.

Returns

bool

Read(HumlNode)

Reads a HumlNode and returns the deserialised T value.

public abstract T? Read(HumlNode node)

Parameters

node HumlNode

The fully-parsed AST node for the value being deserialised.

Returns

T

The deserialised value, or null for nullable types.

Write(HumlWriterContext, T)

Writes value to the serialiser output via context.

public abstract void Write(HumlWriterContext context, T value)

Parameters

context HumlWriterContext

The serialiser context providing append methods.

value T

The value to serialise. Never null for reference types — null values are emitted as null by WriteObject(HumlWriterContext, object) before Write is called.

Remarks

When invoked from a property-level converter context, the output produced by this method is inserted inline as the scalar value for the mapping entry (key: <output>). The output must be a single-line HUML scalar (a quoted string, a number, a keyword such as true / false / null, etc.) — embedded newlines will break the current mapping entry's syntax. Use AppendRaw(string) only when you are certain the output is a valid single-line value.