1
방금 Yaml과 작업하기 시작했고, 약간의 의견을 정말 고맙게 생각합니다. 나는 YAML을 만들고 그것을 기존의 C# 클래스로 황폐화하려고 노력 중이다. 기존 C# 클래스 : 내가 YAML 위를 deserialze 할 때Yaml을 C# 객체로 역 직렬화
[System.Xml.Serialization.XmlIncludeAttribute(typeof(FooType))]
public partial class BarType {
private int barVariable;
public Int Bar {
get {
return this.barVariable;
}
set {
this.barVariable = value;
}
}
}
public partial class FooType : BarType {
private string fooVariable;
public string Foo {
get {
return this.fooVariable;
}
set {
this.fooVariable = value;
}
}
[System.Xml.Serialization.XmlRootAttribute("HeadType", Namespace="xyz", IsNullable=false)]
public partial class HeadType {
private BarType[] barTypesField;
[System.Xml.Serialization.XmlArrayItemAttribute("FooService", typeof(FooType), IsNullable=false)]
public BarType[] BarTypes {
get {
return this.barTypesField;
}
set {
this.barTypesField = value;
}
}
지금 내가 어떤 오류가 발생하지 마십시오 YAML,
HeadType:
- Bar: 0
- Bar: 29
있습니다.
하지만 내 Yaml을 아래와 같이 변경하면 Foo라는 태그에 대해 알지 못합니다.
HeadType:
- Bar: 0
Foo: FooTest
내가이 방법을 사용할 수 있습니까? 내가 YAML 순 직렬화 "YamlDotNet.Serialization을"점 사용하고
HeadType:
FooType:
- Bar: 0
Foo: FooTest
이 직렬화가 작동하는 방법은 다음과 같습니다 :
는 루트 클래스Deserializer deserializer = new Deserializer();
var result = deserializer.Deserialize<RootType>(yamlInput1);
어디도 doesnot 일하는 아래를 시도했다 HeadType을 포함합니다.