Skip to content

Instantly share code, notes, and snippets.

@akira345
Created January 29, 2018 12:59
Show Gist options
  • Save akira345/591473a15e90a7b62ba354ad00a15d56 to your computer and use it in GitHub Desktop.
Save akira345/591473a15e90a7b62ba354ad00a15d56 to your computer and use it in GitHub Desktop.
C#でyaml生成テスト
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using YamlDotNet.Serialization;
namespace yamltest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var calendar = new
{
name = "hoge",
mount = new
{
name = "swap",
src = "{{ swap_file_path }}",
fstype = "swap",
opts = "defaults",
passno = "0",
dump = "0",
state = "present"
}
};
List<object> calenders = new List<object>();
calenders.Add(calendar);
//YAMLにシリアライズしてコンソールに表示
var serializer = new Serializer();
serializer.Serialize(Console.Out, calenders);
Console.Read();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment