【发布时间】:2016-06-05 07:45:06
【问题描述】:
我需要将以下 YAML 反序列化为我的自定义类型。 YamlAlias 属性似乎已经过时,所以我将其替换为 YamlMember。它在反序列化以下 YAML 时失败,但有以下异常:
host: properties: mem_size: 2048 MBYamlDotNet.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; }
}
【问题讨论】:
标签: c# yaml yamldotnet