AddScalarRule(String, String, Func<Match, T>, Func<T, String>?) Method

Definition

Assembly SharpYaml.dll

Add a tag resolution rule that is invoked when regex matches the Scalar a Scalar node. The tag is resolved to tag and decode is invoked when actual value of type T is extracted from the node text.

protected void AddScalarRule<T>(string tag, string regex, Func<Match, T> decode, Func<T, string>? encode)

Type parameters

T
Type of the scalar

Parameters

tag
String

The tag.

regex
String

The regex.

decode
Func<Match, T>

The decode function.

encode
Func<T, String>

The encode function.

Examples

BeginUpdate(); // to avoid invoking slow internal calculation method many times.
Add( ... );
Add( ... );
Add( ... );
Add( ... );
EndUpdate();   // automaticall invoke internal calculation method