次の YAML をカスタム タイプに逆シリアル化する必要があります。YamlAlias 属性は時代遅れのようですので、YamlMember に置き換えました。以下の例外で次の YAML のデシリアライズに失敗します。
host: properties: mem_size: 2048 MB
YamlDotNet.Core.YamlException : (Line: 21, Col: 13, Idx: 524) - (Line: 21, Col: 13, Idx: 524): デシリアライズ中の例外 ----> System.Runtime.Serialization.SerializationException :タイプ「Toscana.Domain.HostProperties」でプロパティ「mem_size」が見つかりません。
public class Host
{
public HostProperties Properties { get; set; }
}
public class HostProperties
{
[YamlMember(typeof(DigitalStorage))]
public string MemSize { get; set; }
}