C#C
C#2y ago
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; }
    }
}


Then i change the sourceFolder: /home to COM_PORT: AUTO -> C# cannot find this item, but i cannot find the error here
Was this page helpful?