Пример #1
0
        private async Task RemoveMenuAsync(string menuText)
        {
            string[] menuStrings = menuText.Split(new char[] { '>' });
            SerializableList <ModuleAction> menu = _SiteMenu;

            for (int si = 0, maxSi = menuStrings.Count(); si < maxSi; ++si)
            {
                string menuString = menuStrings[si].Trim();
                object obj        = await EvaluateVariableAsync(menuString);

                if (obj is ModuleAction)
                {
                    ModuleAction action = (ModuleAction)obj;
                    menuString = action.MenuText.ToString();
                }
                else
                {
                    menuString = (string)obj;
                }
                bool found = false;
                for (int mi = 0; mi < menu.Count(); ++mi)
                {
                    ModuleAction action = menu[mi];
                    if (action.MenuText.ToString() == menuString)
                    {
                        if (si >= maxSi - 1)
                        {
                            // last string entry, remove menu entry
                            if (action.SubMenu == null || action.SubMenu.Count() == 0)
                            {
                                menu.RemoveAt(mi);
                                return;
                            }
                        }
                        else
                        {
                            if (action.SubMenu != null && action.SubMenu.Count() > 0)
                            {
                                menu  = action.SubMenu;
                                found = true;
                                break;
                            }
                        }
                    }
                }
                if (!found)
                {
                    return;
                }
            }
        }