protected void AddFolderToFolder(IEnumerable<XElement> list, IPublicComposite folder)
 {
     foreach (var xElement in list)
         {
             var childrenfolder = new Folder()
                        {
                            Id = ((XElement) xElement.PreviousNode).Value,
                            IdFather = folder.Id,
                            Name = xElement.Value,
                            Price = "This folder!"
                        };
             folder.AddComponent(childrenfolder);
             GetChildren(((XElement)xElement).Value, childrenfolder);
         }
 }
        public void TestMethodMenuToList()
        {
            ComReader.Start();
            DG = new DGobject { XelementMenu = ComReader.GetMenuToBuffer() };
            //var xml = new MenuXml();
            //var menu = xml.MenuXmlToList(DG.Menu);
            var xml = new MenuXmlParser();
            var menu = new Folder(){Id = "Главный фолдер"};
            foreach (var xElement in xml.GetButtonName(DG.XelementMenu))
            {
                menu.AddComponent(xml.BuildMenu(xElement));
            }

            var cc = menu.FindId("bb118da8-053c-11e0-8cad-20cf308e5b25");
            var ccc = (IModifiers)menu.FindId("e450b94c-0540-11e0-8cad-20cf308e5b25");
            var mod = ccc.GetModifiers();
            ComReader.Stop();
        }
        public IPublicComponent BuildMenu(XElement doc)
        {
            _doc = doc;
            _menu = new Folder();
            //ПАПКИ с блюдами на тесте 62 папки
            var rootMenu = _doc./*Elements("ButtonName").*/Elements("ItemName").Elements("Наименование");
            foreach (var xElement in rootMenu)
            {
                var folder = new Folder(){
                    Id = ((XElement)xElement.PreviousNode).Value,
                                        Name = xElement.Value,
                                        Price = "This Bigfolder!"
                };

                GetChildren(((XElement)xElement).Value, folder);
                _menu.AddComponent(folder);
            }
            return _menu;
        }
        //Обработка для каждого ButtonName
        public IPublicComponent BuildMenu(XElement doc)
        {
            _doc = doc;
            _menu = new Folder();
            var element = _doc.Element("Наименование");
            if (element != null) _menu.Name = element.Value;

            //ПАПКИ с блюдами на тесте 17 папки
            var rootMenu = _doc.Elements("ItemName").Elements("Наименование");
            foreach (var folder in rootMenu.Select(xElement => new Folder(){
                                                                               Id = ((XElement)xElement.PreviousNode).Value,
                                                                               Name = xElement.Value,
                                                                               Price = "This Bigfolder!",
                                                                               IdFather = "This Bigfolder!"
                                                                           }))
            {
                GetChildren(folder.Id, folder);
                _menu.AddComponent(folder);
            }
            return _menu;
        }