Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //StreamReader reader = new StreamReader("c:\\tmp\\en.yml");
            StreamReader reader = new StreamReader("c:\\tmp\\de.yml");

            TextInput input = new TextInput(reader.ReadToEnd());

            bool success;
            YamlParser parser = new YamlParser();
            YamlStream yamlStream = parser.ParseYamlStream(input, out success);
            if (success)
            {
                foreach (YamlDocument doc in yamlStream.Documents)
                {
                    TreeNode rootNode = YamlEmittor.CreateNode(doc.Root);
                    treeView1.Nodes.Add(rootNode);

                    foreach (TreeNode node in rootNode.Nodes)
                    {
                        richTextBox1.AppendText(node.Text);
                    }
                }
            }
            else
            {
                richTextBox1.Text = parser.GetErrorMessages();
            }
        }
Exemplo n.º 2
0
 public static YamlStream Load(string file)
 {
     string text = File.ReadAllText(file);
     TextInput input = new TextInput(text);
     YamlParser parser = new YamlParser();
     bool success;
     YamlStream stream = parser.ParseYamlStream(input, out success);
     if (success)
     {
         return stream;
     }
     else
     {
         string message = parser.GetErrorMessages();
         throw new Exception(message);
     }
 }
Exemplo n.º 3
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            richTextBox1.Visible = false;
            treeView1.Visible = true;

            StreamReader reader = new StreamReader(fileName);

            TextInput input = new TextInput(reader.ReadToEnd());

            bool success;
            YamlParser parser = new YamlParser();
            YamlStream yamlStream = parser.ParseYamlStream(input, out success);
            if (success)
            {

                foreach (YamlDocument doc in yamlStream.Documents)
                {
                    TreeNode rootNode = YamlEmittor.CreateNode(doc.Root);
                    treeView1.Nodes.Add(rootNode);

                    ProcessTreeNode(rootNode);
                }

                tabControl1.SelectedIndex = 0;
            }
            else
            {
                treeView1.Visible = false;
                richTextBox1.Visible = true;
                richTextBox1.Text = parser.GetErrorMessages();
                tabControl1.SelectedIndex = 1;
                richTextBox1.Focus();
            }
            reader.Close();
        }