Exemple #1
0
        //OVERLOADING
        private void LoadChildren(YamlSequenceNode sequence, MyYamlNode parent)
        {
            foreach (var child in sequence.Children)
            {
                if (child is YamlScalarNode)
                {
                    var scalar = child as YamlScalarNode;
                    parent.AddChildren(MyNodeFactory.CreateMyYamlScalarNode("", scalar.Tag, scalar.Value, scalar.Style, indentAmount));

                    //CANT HAVE INCLUDE IN SEQUENCE CHILDREN???

                    /* if (scalar.Tag == "!include")
                     * {
                     *  LoadFile(node, scalar.Value);
                     * } */
                }
                else if (child is YamlSequenceNode)
                {
                    parent.AddChildren(MyNodeFactory.CreateMyYamlSequenceNode("", indentAmount));

                    MyYamlSequenceNode new_parent = (MyYamlSequenceNode)parent.nodes[parent.nodes.Count - 1];
                    LoadChildren(child as YamlSequenceNode, new_parent);
                }
                else if (child is YamlMappingNode)
                {
                    parent.AddChildren(MyNodeFactory.CreateMyYamlMappingNode("", indentAmount));

                    MyYamlMappingNode new_parent = (MyYamlMappingNode)parent.nodes[parent.nodes.Count - 1];
                    LoadChildren(child as YamlMappingNode, new_parent);
                }
            }
        }
Exemple #2
0
 public abstract void AddChildren(MyYamlNode child);
Exemple #3
0
 public void AddChildren(MyYamlNode child, List <MyYamlNode> nodes)
 {
     nodes.Add(child);
 }
Exemple #4
0
 public override void AddChildren(MyYamlNode child)
 {
     this.nodes.Add(child);
 }
Exemple #5
0
 public override void AddChildren(MyYamlNode child)
 {
 }
Exemple #6
0
        //OVERLOADING
        private void LoadChildren(YamlMappingNode mapping, MyYamlNode parent)
        {
            var children = mapping?.Children;

            if (children == null)
            {
                return;
            }

            foreach (var child in children)
            {
                var key = child.Key as YamlScalarNode;
                System.Diagnostics.Trace.Assert(key != null);

                if (child.Value is YamlScalarNode)
                {
                    var scalar = child.Value as YamlScalarNode;
                    parent.AddChildren(MyNodeFactory.CreateMyYamlScalarNode(key.Value, scalar.Tag, scalar.Value, scalar.Style, indentAmount));

                    if (scalar.Tag == "!include")
                    {
                        if (File.Exists(directory + scalar.Value))
                        {
                            new MyYamlFile(directory + scalar.Value);
                        }
                        else
                        {
                            Logger.Instance.WriteLine("Could not find file '" + directory + scalar.Value + "'.");
                        }
                    }
                    if (scalar.Tag == "!include_dir_named")
                    {
                        System.IO.Directory.CreateDirectory(directory + scalar.Value);//Create directory if doesnt exists
                        string[] files = System.IO.Directory.GetFiles(directory + scalar.Value + "/", "*.yaml");
                        foreach (var value in files)
                        {
                            var value_split    = value.Split("/");
                            var file_to_import = value_split[value_split.Length - 1];
                            if (File.Exists(directory + scalar.Value + "/" + file_to_import))
                            {
                                new MyYamlFile(directory + scalar.Value + "/" + file_to_import);
                            }
                            else
                            {
                                Logger.Instance.WriteLine("Could not find file '" + directory + scalar.Value + "/" + file_to_import + "'.");
                            }
                        }
                    }
                }
                else if (child.Value is YamlSequenceNode)
                {
                    parent.AddChildren(MyNodeFactory.CreateMyYamlSequenceNode(key.Value, indentAmount));

                    indentAmount += 2;
                    MyYamlSequenceNode new_parent = (MyYamlSequenceNode)parent.nodes[parent.nodes.Count - 1];
                    LoadChildren(child.Value as YamlSequenceNode, new_parent);
                    indentAmount -= 2;
                }
                else if (child.Value is YamlMappingNode)
                {
                    parent.AddChildren(MyNodeFactory.CreateMyYamlMappingNode(key.Value, indentAmount));

                    indentAmount += 2;
                    MyYamlMappingNode new_parent = (MyYamlMappingNode)parent.nodes[parent.nodes.Count - 1];
                    LoadChildren(child.Value as YamlMappingNode, new_parent);
                    indentAmount -= 2;
                }
            }
        }