示例#1
0
        private void AddDynamicChildElement(XmlElement parentElement, ModMenuItem element)
        {
            XmlNode copy = parentElement.OwnerDocument.ImportNode(element.MenuXml.GetXmlElement(), true);

            if (!String.IsNullOrEmpty(element.Parent))
            {
                XmlNode parentNode =
                    parentElement.OwnerDocument.SelectSingleNode("descendant::siteMapNode[@key='" +
                                                                 element.Parent + "']");
                if (!String.IsNullOrEmpty(element.InsertAfter))
                {
                    XmlNode afterNode =
                        parentElement.SelectSingleNode("descendant::siteMapNode[@key='" +
                                                       element.InsertAfter + "']");
                    parentNode.InsertAfter(copy, afterNode);
                }
                else
                {
                    parentNode.AppendChild(copy);
                }
            }
            else if (!String.IsNullOrEmpty(element.InsertAfter))
            {
                XmlNode afterNode =
                    parentElement.OwnerDocument.SelectSingleNode("descendant::siteMapNode[@key='" +
                                                                 element.InsertAfter + "']");
                parentElement.InsertAfter(copy, afterNode);
            }
            else
            {
                parentElement.AppendChild(copy);
            }
        }
示例#2
0
        public static List <ModMenuItem> GetMenuItems()
        {
            List <ModMenuItem> menuitems = new List <ModMenuItem>();

            foreach (string modconfig in GetModConfigs())
            {
                Type modclass = Type.GetType("ModConfig." + modconfig + ",App_Code", true);
                if (modclass != null)
                {
                    object modInstance = Activator.CreateInstance(modclass);
                    var    enabled     = modclass.GetProperty("Enabled").GetValue(modInstance, null);
                    var    showmenu    = modclass.GetProperty("ShowOnMenu").GetValue(modInstance, null);
                    if (Convert.ToBoolean(enabled) && Convert.ToBoolean(showmenu))
                    {
                        ModMenuItem menu = (ModMenuItem)modclass.GetProperty("Menu").GetValue(modInstance, null);

                        menuitems.Add(menu);
                    }
                }
            }
            return(menuitems);
        }