public void MenuUtility_ToTree_1() { MenuFile menu = new MenuFile(); menu.Add("1", "First"); menu.Add("1.1", "First first"); menu.Add("1.1.1", "First first first"); menu.Add("1.1.2", "First first second"); menu.Add("1.2", "First second"); menu.Add("1.2.1", "First second first"); menu.Add("2", "Second"); IrbisTreeFile tree = menu.ToTree(); Assert.AreEqual(2, tree.Roots.Count); }
static int Main(string[] args) { if (args.Length < 1 || args.Length > 2) { Console.WriteLine("Usage: Mnu2Tre <input> [output]"); return(1); } string inputName = args[0].ThrowIfNull(); string outputName = args.Length == 1 ? Path.ChangeExtension(inputName, ".tre") : args[1]; try { MenuFile menu = MenuFile.ParseLocalFile ( inputName, IrbisEncoding.Ansi ); IrbisTreeFile tree = menu.ToTree(); tree.SaveToLocalFile ( outputName, IrbisEncoding.Ansi ); } catch (Exception e) { Console.WriteLine(e); return(1); } return(0); }