示例#1
0
        private void _InitTree(XmlNode node, TagItem tagItem)
        {
            XmlNodeList childs = node.ChildNodes;
            XmlNode     child;
            TagItem     tI;

            //Node isn't content a content and other node at the same time
            //One node in list is empty or string including node
            if (childs.Count > 0)
            {
                for (int i = 0; i < childs.Count; i++)
                {
                    child = childs.Item(i);

                    //Checking it's child no more include tag
                    if (child.LocalName == "#text")
                    {
                        tI = new TagItem(tagItem.NodeName,
                                         child.Value,
                                         tagItem.parent);
                        try{
                            tagItem.parent.Add(tI);
                            tagItem.parent.Remove(tagItem);
                        }
                        catch (NullReferenceException) {
                            Console.WriteLine("In terms of a task a root " +
                                              "node have to a \"none\" type cause " +
                                              "it doesn\'t read xml files contaning" +
                                              " numeric root");
                            //System.Environment.Exit(0);
                            return;
                        }
                        continue;
                    }

                    //Assign tag name for TagItem's item with empty content
                    tI = new TagItem(child.Name, "", tagItem);
                    tagItem.Add(tI);

                    //go in depth
                    _InitTree(child, tI);
                }
            }
            else
            {
                //There isn't tag anymore. Assign content
                tagItem.content = node.Value;
                return;
            }
        }
示例#2
0
        public void Transfer(TagItem newParent)
        {
            //Checking newParent is not for child of moving node
            TagItem tag = Search(newParent.fullName);

            if (tag != null)
            {
                Console.WriteLine("Transfer aborted. {0} is parent for {1}",
                                  fullName, newParent.fullName);
                return;
            }

            newParent.Add(this);
            parent.Remove(this);
            parent = newParent;

            _Refresh();
            Console.WriteLine("Transfer done.");
        }
示例#3
0
        static public void Add()
        {
            TagItem root = storage.root;

            Console.WriteLine("Choose parent tag");
            string  path   = Console.ReadLine();
            TagItem parent = root.Search(path);

            if (parent != null)
            {
                Console.WriteLine("Suggest name of tag");
                string name = Console.ReadLine();
                Console.WriteLine("What\'s data type it will be?");
                string type = Console.ReadLine();

                TagItem tag;

                switch (type)
                {
                case "int":
                    tag = new TagItem(name, "", parent, type);
                    break;

                case "float":
                    tag = new TagItem(name, "", parent, type);
                    break;

                case "bool":
                    tag = new TagItem(name, "", parent, type);
                    break;

                default:
                    tag = new TagItem(name, "", parent, "none");
                    break;
                }

                parent.Add(tag);
                Console.WriteLine("{0} is added to tree", tag.fullName);
                return;
            }
            Console.WriteLine("Tag {0} is absent. Nothing add", path);
        }