static public void Remove() { TagItem root = storage.root; Console.WriteLine("What tag you want to remove?\n" + "Name of tag with path require"); string expr = Console.ReadLine(); //Get wanted tag TagItem tag = root.Search(expr); if (tag != null) { if (tag.parent != null) { tag.parent.Remove(tag); } else { //Attempt to remove a structure's root storage = new TagStorage(FILE_NAME); } Console.WriteLine("Deleted"); return; } Console.WriteLine("Tag is absent. Nothing delete"); }
static public void Load() { storage = new TagStorage(FILE_NAME); storage.LoadXml(); }
static void Main(string[] args) { storage = new TagStorage(FILE_NAME); string stars = "\n************************************"; string menu = "\nPress a key suggested menu\n" + "\'r\' : Read in.xml\n" + "\'w\' : Write to out.xml\n" + "\'p\' : Print a tree\n" + "\'a\' : Add a tag\n" + "\'d\' : Delete a tag\n" + "\'c\' : Change a tag's name\n" + "\'h\' : Show menu\n" + "\'q\' : Quit\n" + "Additional:\n" + "\'m\' : Moving tag\n" + "\'s\' : Set new value to a tag\n"; Console.WriteLine(menu); for (; ;) { char key = (char)Console.Read(); switch (key) { case 'r': Console.WriteLine(stars); Load(); Console.WriteLine("\n\'h\' : Show menu\n"); break; case 'w': Console.WriteLine(stars); Save(); Console.WriteLine("\n\'h\' : Show menu\n"); break; case 'p': Console.WriteLine(stars); Print(); Console.WriteLine("\n\'h\' : Show menu\n"); break; case 'a': Console.WriteLine(stars); Add(); Console.WriteLine("\n\'h\' : Show menu\n"); break; case 'd': Console.WriteLine(stars); Remove(); Console.WriteLine("\n\'h\' : Show menu\n"); break; case 'c': Console.WriteLine(stars); Rename(); Console.WriteLine("\n\'h\' : Show menu\n"); break; case 'h': Console.WriteLine(stars); Console.WriteLine(menu); break; case 'q': Console.WriteLine(stars); Console.WriteLine("Exit"); System.Environment.Exit(0); break; case 'm': Console.WriteLine(stars); Transfer(); Console.WriteLine("\n\'h\' : Show menu\n"); break; case 's': Console.WriteLine(stars); SetContent(); Console.WriteLine("\n\'h\' : Show menu\n"); break; } } }