Trixxtar
C# Yaml error
using System.Windows.Forms;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
namespace HWScreen
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
var yaml = @"config:
sourceFolder: /home
destinationFolder: /home/billy/my-test-case";
var deserializer = new DeserializerBuilder()
.WithNamingConvention(CamelCaseNamingConvention.Instance)
.Build();
var obj = deserializer.Deserialize<MyModel>(yaml);
//obj.Dump();
textBox1.Text += (obj.config.sourceFolder);
}
}
public class MyModel
{
[YamlMember(Alias = "config", ApplyNamingConventions = false)]
public config config { get; set; }
}
public class config
{
public string sourceFolder { get; set; }
public string DestinationFolder { get; set; }
}
}
using System.Windows.Forms;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
namespace HWScreen
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
var yaml = @"config:
sourceFolder: /home
destinationFolder: /home/billy/my-test-case";
var deserializer = new DeserializerBuilder()
.WithNamingConvention(CamelCaseNamingConvention.Instance)
.Build();
var obj = deserializer.Deserialize<MyModel>(yaml);
//obj.Dump();
textBox1.Text += (obj.config.sourceFolder);
}
}
public class MyModel
{
[YamlMember(Alias = "config", ApplyNamingConventions = false)]
public config config { get; set; }
}
public class config
{
public string sourceFolder { get; set; }
public string DestinationFolder { get; set; }
}
}
12 replies