예제 #1
0
        public static void LoadChildren(SequenceNode root, YamlSequenceNode sequence)
        {
            foreach (var child in sequence.Children)
            {
                if (child is YamlSequenceNode)
                {
                    var node = root.AddChild(new SequenceNode(root.Value, child, ImageLoad.GetImageIndex(child), id, root));
                    id++;
                    LoadChildren(node as SequenceNode, child as YamlSequenceNode);
                }
                else if (child is YamlMappingNode)
                {
                    var teste = child as YamlMappingNode;
                    var node  = root.AddChild(new MappingNode(root.Value, child, ImageLoad.GetImageIndex(child), id, root));
                    id++;

                    LoadChildren(node as MappingNode, child as YamlMappingNode);
                }
                else if (child is YamlScalarNode)
                {
                    var scalar = child as YamlScalarNode;
                    var node   = root.AddChild(new ScalarNode(scalar.Value, child, scalar.Tag, ImageLoad.GetImageIndex(child), id, root));
                    id++;
                }
            }
        }
예제 #2
0
        public static void LoadChildren(MappingNode root, YamlMappingNode mapping)
        {
            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;

                    if (scalar.Tag == "!include")
                    {
                        MappingNode scalarToMapping = (MappingNode)root.AddChild(new MappingNode(scalar.Value, scalar.Tag, ImageLoad.GetImageIndex(scalar), id, root));
                        id++;

                        var yaml = FileHandler.LoadFile(scalarToMapping as MappingNode, scalar.Value);
                        if (yaml.Documents.Count == 0)
                        {
                            continue;
                        }

                        //scalarToMapping.AddChild(newRoot);
                        LoadChildren(scalarToMapping, yaml.Documents[0].RootNode as YamlMappingNode);
                        continue;
                    }

                    ScalarNode scalarToSave = new ScalarNode(scalar.Value, child, scalar.Tag, ImageLoad.GetImageIndex(scalar), id, root, key.Value);
                    id++;
                    if (scalar.Tag == "!secret")
                    {
                        scalarToSave.Property   = scalar.Tag;
                        scalarToSave.ImageIndex = 2;
                    }
                    var node = root.AddChild(scalarToSave);
                }
                else if (child.Value is YamlSequenceNode)
                {
                    var node = root.AddChild(new SequenceNode(key.Value, child.Value, ImageLoad.GetImageIndex(child.Value), id, root));
                    id++;

                    LoadChildren(node as SequenceNode, child.Value as YamlSequenceNode);
                }
                else if (child.Value is YamlMappingNode)
                {
                    var node = root.AddChild(new MappingNode(key.Value, child.Value, ImageLoad.GetImageIndex(child.Value), id, root));
                    id++;
                    LoadChildren(node as MappingNode, child.Value as YamlMappingNode);
                }
            }
        }