private static void Iterate(SiteMapNode siteMapNode, XmlNode xmlNode) { PopulateNode(siteMapNode, xmlNode); foreach (XmlNode xmlChildNode in xmlNode.ChildNodes) { if (!xmlChildNode.LocalName.Equals("siteMapNode", StringComparison.InvariantCultureIgnoreCase)) continue; var siteMapChildNode = new SiteMapNode(); siteMapNode.ChildNodes.Add(siteMapChildNode); Iterate(siteMapChildNode, xmlChildNode); } }
private static void PopulateNode(SiteMapNode siteMapNode, XmlNode xmlNode) { //titulo var softResource = GetStringValueFromAttribute(xmlNode, "softResource"); if (!string.IsNullOrEmpty(softResource)) { siteMapNode.Title = softResource; } else { siteMapNode.Title = GetStringValueFromAttribute(xmlNode, "title"); } //routes, url var controllerName = GetStringValueFromAttribute(xmlNode, "controller"); var actionName = GetStringValueFromAttribute(xmlNode, "action"); var url = GetStringValueFromAttribute(xmlNode, "url"); if (!string.IsNullOrEmpty(controllerName) && !string.IsNullOrEmpty(actionName)) { siteMapNode.ControllerName = controllerName; siteMapNode.ActionName = actionName; //apply admin area as described here - http://www.nopcommerce.com/boards/t/20478/broken-menus-in-admin-area-whilst-trying-to-make-a-plugin-admin-page.aspx siteMapNode.RouteValues = new RouteValueDictionary { { "area", "Admin" } }; } else if (!string.IsNullOrEmpty(url)) { siteMapNode.Url = url; } //image URL siteMapNode.ImageUrl = GetStringValueFromAttribute(xmlNode, "ImageUrl"); //permission name var permissionNames = GetStringValueFromAttribute(xmlNode, "PermissionNames"); if (!string.IsNullOrEmpty(permissionNames)) { var permissionService = EngineContext.Current.Resolve<IPermissionService>(); siteMapNode.Visible = permissionNames.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Any(permissionName => permissionService.Authorize(permissionName.Trim())); } else { siteMapNode.Visible = true; } }
public XmlSiteMap() { RootNode = new SiteMapNode(); }