private NavigationNode BuildNavNode(XElement xmlNode) { NavigationNode navNode = new NavigationNode(); var a = xmlNode.Attribute("key"); if (a != null) { navNode.Key = a.Value; } a = xmlNode.Attribute("parentKey"); if (a != null) { navNode.ParentKey = a.Value; } a = xmlNode.Attribute("controller"); if (a != null) { navNode.Controller = a.Value; } a = xmlNode.Attribute("action"); if (a != null) { navNode.Action = a.Value; } a = xmlNode.Attribute("text"); if (a != null) { navNode.Text = a.Value; } a = xmlNode.Attribute("title"); if (a != null) { navNode.Title = a.Value; } a = xmlNode.Attribute("url"); if (a != null) { navNode.Url = a.Value; } else { navNode.Url = navNode.ResolveUrl(); } a = xmlNode.Attribute("isRootNode"); if (a != null) { navNode.IsRootNode = Convert.ToBoolean(a.Value); } a = xmlNode.Attribute("includeAmbientValuesInUrl"); if (a != null) { navNode.IncludeAmbientValuesInUrl = Convert.ToBoolean(a.Value); } a = xmlNode.Attribute("resourceName"); if (a != null) { navNode.ResourceName = a.Value; } a = xmlNode.Attribute("resourceTextKey"); if (a != null) { navNode.ResourceTextKey = a.Value; } a = xmlNode.Attribute("resourceTitleKey"); if (a != null) { navNode.ResourceTitleKey = a.Value; } a = xmlNode.Attribute("preservedRouteParameters"); if (a != null) { navNode.PreservedRouteParameters = a.Value; } a = xmlNode.Attribute("componentVisibility"); if (a != null) { navNode.ComponentVisibility = a.Value; } a = xmlNode.Attribute("viewRoles"); if (a != null) { navNode.ViewRoles = a.Value; } return(navNode); }
private NavigationNode BuildNavNode( XElement xmlNode, NavigationTreeBuilderService service ) { NavigationNode navNode = new NavigationNode(); //var tb = xmlNode.Attribute("TreeBuilderName"); //if (tb != null) //{ // return await service.GetTree(tb.Value).ConfigureAwait(false) //} var a = xmlNode.Attribute("key"); if (a != null) { navNode.Key = a.Value; } a = xmlNode.Attribute("parentKey"); if (a != null) { navNode.ParentKey = a.Value; } a = xmlNode.Attribute("controller"); if (a != null) { navNode.Controller = a.Value; } a = xmlNode.Attribute("action"); if (a != null) { navNode.Action = a.Value; } a = xmlNode.Attribute("area"); if (a != null) { navNode.Area = a.Value; } a = xmlNode.Attribute("namedRoute"); if (a == null) { a = xmlNode.Attribute("named-route"); //this is not consistent was a mistake } if (a != null) { navNode.NamedRoute = a.Value; } a = xmlNode.Attribute("text"); if (a != null) { navNode.Text = a.Value; } a = xmlNode.Attribute("title"); if (a != null) { navNode.Title = a.Value; } a = xmlNode.Attribute("url"); if (a != null) { navNode.Url = a.Value; } else { navNode.Url = navNode.ResolveUrl(); // this smells bad } a = xmlNode.Attribute("isRootNode"); if (a != null) { navNode.IsRootNode = Convert.ToBoolean(a.Value); } a = xmlNode.Attribute("hideFromAuthenticated"); if (a != null) { navNode.HideFromAuthenticated = Convert.ToBoolean(a.Value); } a = xmlNode.Attribute("hideFromAnonymous"); if (a != null) { navNode.HideFromAnonymous = Convert.ToBoolean(a.Value); } //a = xmlNode.Attribute("includeAmbientValuesInUrl"); //if (a != null) { navNode.IncludeAmbientValuesInUrl = Convert.ToBoolean(a.Value); } //a = xmlNode.Attribute("resourceName"); //if (a != null) { navNode.ResourceName = a.Value; } //a = xmlNode.Attribute("resourceTextKey"); //if (a != null) { navNode.ResourceTextKey = a.Value; } //a = xmlNode.Attribute("resourceTitleKey"); //if (a != null) { navNode.ResourceTitleKey = a.Value; } a = xmlNode.Attribute("preservedRouteParameters"); if (a != null) { navNode.PreservedRouteParameters = a.Value; } a = xmlNode.Attribute("componentVisibility"); if (a != null) { navNode.ComponentVisibility = a.Value; } a = xmlNode.Attribute("viewRoles"); if (a != null) { navNode.ViewRoles = a.Value; } a = xmlNode.Attribute("customData"); if (a != null) { navNode.CustomData = a.Value; } a = xmlNode.Attribute("isClickable"); if (a != null) { navNode.IsClickable = Convert.ToBoolean(a.Value); } a = xmlNode.Attribute("iconCssClass"); if (a != null) { navNode.IconCssClass = a.Value; } a = xmlNode.Attribute("cssClass"); if (a != null) { navNode.CssClass = a.Value; } a = xmlNode.Attribute("menuDescription"); if (a != null) { navNode.MenuDescription = a.Value; } a = xmlNode.Attribute("target"); if (a != null) { navNode.Target = a.Value; } var da = xmlNode.Element(XName.Get("DataAttributes")); if (da != null) { foreach (XElement childNode in da.Elements(XName.Get("DataAttribute"))) { var key = childNode.Attribute("attribute"); var val = childNode.Attribute("value"); if ((key != null) && (val != null)) { var att = new DataAttribute(); att.Attribute = key.Value; att.Value = val.Value; navNode.DataAttributes.Add(att); } } } return(navNode); }
private NavigationNode BuildNavNode(XElement xmlNode) { NavigationNode navNode = new NavigationNode(); var a = xmlNode.Attribute("key"); if(a != null) { navNode.Key = a.Value; } a = xmlNode.Attribute("parentKey"); if (a != null) { navNode.ParentKey = a.Value; } a = xmlNode.Attribute("controller"); if (a != null) { navNode.Controller = a.Value; } a = xmlNode.Attribute("action"); if (a != null) { navNode.Action = a.Value; } a = xmlNode.Attribute("text"); if (a != null) { navNode.Text = a.Value; } a = xmlNode.Attribute("title"); if (a != null) { navNode.Title = a.Value; } a = xmlNode.Attribute("url"); if (a != null) { navNode.Url = a.Value; } else { navNode.Url = navNode.ResolveUrl(); } a = xmlNode.Attribute("isRootNode"); if (a != null) { navNode.IsRootNode = Convert.ToBoolean(a.Value); } a = xmlNode.Attribute("includeAmbientValuesInUrl"); if (a != null) { navNode.IncludeAmbientValuesInUrl = Convert.ToBoolean(a.Value); } a = xmlNode.Attribute("resourceName"); if (a != null) { navNode.ResourceName = a.Value; } a = xmlNode.Attribute("resourceTextKey"); if (a != null) { navNode.ResourceTextKey = a.Value; } a = xmlNode.Attribute("resourceTitleKey"); if (a != null) { navNode.ResourceTitleKey = a.Value; } a = xmlNode.Attribute("preservedRouteParameters"); if (a != null) { navNode.PreservedRouteParameters = a.Value; } a = xmlNode.Attribute("componentVisibility"); if (a != null) { navNode.ComponentVisibility = a.Value; } a = xmlNode.Attribute("viewRoles"); if (a != null) { navNode.ViewRoles = a.Value; } return navNode; }
private NavigationNode BuildNavNode( XElement xmlNode, NavigationTreeBuilderService service ) { NavigationNode navNode = new NavigationNode(); //var tb = xmlNode.Attribute("TreeBuilderName"); //if (tb != null) //{ // return await service.GetTree(tb.Value).ConfigureAwait(false) //} var a = xmlNode.Attribute("key"); if(a != null) { navNode.Key = a.Value; } a = xmlNode.Attribute("parentKey"); if (a != null) { navNode.ParentKey = a.Value; } a = xmlNode.Attribute("controller"); if (a != null) { navNode.Controller = a.Value; } a = xmlNode.Attribute("action"); if (a != null) { navNode.Action = a.Value; } a = xmlNode.Attribute("area"); if (a != null) { navNode.Area = a.Value; } a = xmlNode.Attribute("namedRoute"); if(a == null) a = xmlNode.Attribute("named-route"); //this is not consistent was a mistake if (a != null) { navNode.NamedRoute = a.Value; } a = xmlNode.Attribute("text"); if (a != null) { navNode.Text = a.Value; } a = xmlNode.Attribute("title"); if (a != null) { navNode.Title = a.Value; } a = xmlNode.Attribute("url"); if (a != null) { navNode.Url = a.Value; } else { navNode.Url = navNode.ResolveUrl(); // this smells bad } a = xmlNode.Attribute("isRootNode"); if (a != null) { navNode.IsRootNode = Convert.ToBoolean(a.Value); } a = xmlNode.Attribute("hideFromAuthenticated"); if (a != null) { navNode.HideFromAuthenticated = Convert.ToBoolean(a.Value); } a = xmlNode.Attribute("hideFromAnonymous"); if (a != null) { navNode.HideFromAnonymous = Convert.ToBoolean(a.Value); } //a = xmlNode.Attribute("includeAmbientValuesInUrl"); //if (a != null) { navNode.IncludeAmbientValuesInUrl = Convert.ToBoolean(a.Value); } //a = xmlNode.Attribute("resourceName"); //if (a != null) { navNode.ResourceName = a.Value; } //a = xmlNode.Attribute("resourceTextKey"); //if (a != null) { navNode.ResourceTextKey = a.Value; } //a = xmlNode.Attribute("resourceTitleKey"); //if (a != null) { navNode.ResourceTitleKey = a.Value; } a = xmlNode.Attribute("preservedRouteParameters"); if (a != null) { navNode.PreservedRouteParameters = a.Value; } a = xmlNode.Attribute("componentVisibility"); if (a != null) { navNode.ComponentVisibility = a.Value; } a = xmlNode.Attribute("viewRoles"); if (a != null) { navNode.ViewRoles = a.Value; } a = xmlNode.Attribute("customData"); if (a != null) { navNode.CustomData = a.Value; } a = xmlNode.Attribute("isClickable"); if (a != null) { navNode.IsClickable = Convert.ToBoolean(a.Value); } a = xmlNode.Attribute("iconCssClass"); if (a != null) { navNode.IconCssClass = a.Value; } a = xmlNode.Attribute("cssClass"); if (a != null) { navNode.CssClass = a.Value; } a = xmlNode.Attribute("menuDescription"); if (a != null) { navNode.MenuDescription = a.Value; } a = xmlNode.Attribute("target"); if (a != null) { navNode.Target = a.Value; } var da = xmlNode.Element(XName.Get("DataAttributes")); if (da != null) { foreach (XElement childNode in da.Elements(XName.Get("DataAttribute"))) { var key = childNode.Attribute("attribute"); var val = childNode.Attribute("value"); if ((key != null) && (val != null)) { var att = new DataAttribute(); att.Attribute = key.Value; att.Value = val.Value; navNode.DataAttributes.Add(att); } } } return navNode; }
#pragma warning restore 1998 private TreeNode<NavigationNode> BuildTree() { NavigationNode home = new NavigationNode(); home.Key = "Home"; home.ParentKey = "RootNode"; home.Controller = "Home"; home.Action = "Index"; home.Text = "Home"; home.Url = home.ResolveUrl(); home.IsRootNode = true; TreeNode<NavigationNode> treeRoot = new TreeNode<NavigationNode>(home); NavigationNode about = new NavigationNode(); about.Key = "About"; about.ParentKey = "RootNode"; about.Controller = "Home"; about.Action = "About"; about.Text = "About"; about.Url = about.ResolveUrl(); treeRoot.AddChild(about); NavigationNode contact = new NavigationNode(); contact.Key = "Contact"; contact.ParentKey = "RootNode"; contact.Controller = "Home"; contact.Action = "Contact"; contact.Text = "Contact"; contact.Url = contact.ResolveUrl(); treeRoot.AddChild(contact); NavigationNode siteAdmin = new NavigationNode(); siteAdmin.Key = "SiteAdmin"; siteAdmin.ParentKey = "RootNode"; siteAdmin.Controller = "SiteAdmin"; siteAdmin.Action = "Index"; siteAdmin.Text = "Administration"; siteAdmin.ViewRoles = "Admins,Content Administrators"; siteAdmin.Url = siteAdmin.ResolveUrl(); TreeNode<NavigationNode> adminRoot = treeRoot.AddChild(siteAdmin); NavigationNode siteSettings = new NavigationNode(); siteSettings.Key = "BasicSettings"; siteSettings.ParentKey = "SiteAdmin"; siteSettings.Controller = "SiteAdmin"; siteSettings.Action = "SiteInfo"; siteSettings.Text = "Site Settings"; siteSettings.ViewRoles = "Admins,Content Administrators"; siteSettings.ComponentVisibility = NamedNavigationFilters.Breadcrumbs + "," + NamedNavigationFilters.ChildTree; siteSettings.PreservedRouteParameters = "siteGuid"; siteSettings.Url = siteSettings.ResolveUrl(); TreeNode<NavigationNode> siteT = adminRoot.AddChild(siteSettings); NavigationNode hosts = new NavigationNode(); hosts.Key = "SiteHostMappings"; hosts.ParentKey = "BasicSettings"; hosts.Controller = "SiteAdmin"; hosts.Action = "SiteHostMappings"; hosts.Text = "Domain Mappings"; hosts.ViewRoles = "Admins,Content Administrators"; hosts.ComponentVisibility = NamedNavigationFilters.Breadcrumbs; hosts.PreservedRouteParameters = "siteGuid"; hosts.Url = hosts.ResolveUrl(); TreeNode<NavigationNode> hostsT = siteT.AddChild(hosts); NavigationNode siteList = new NavigationNode(); siteList.Key = "SiteList"; siteList.ParentKey = "SiteAdmin"; siteList.Controller = "SiteAdmin"; siteList.Action = "SiteList"; siteList.Text = "SiteList"; siteList.ViewRoles = "ServerAdmins"; siteList.ComponentVisibility = NamedNavigationFilters.Breadcrumbs + "," + NamedNavigationFilters.ChildTree; siteList.Url = siteList.ResolveUrl(); TreeNode<NavigationNode> siteListT = adminRoot.AddChild(siteList); NavigationNode newSite = new NavigationNode(); newSite.Key = "NewSite"; newSite.ParentKey = "SiteList"; newSite.Controller = "SiteAdmin"; newSite.Action = "NewSite"; newSite.Text = "NewSite"; newSite.ViewRoles = "ServerAdmins"; newSite.ComponentVisibility = NamedNavigationFilters.Breadcrumbs + "," + NamedNavigationFilters.ChildTree; newSite.Url = newSite.ResolveUrl(); TreeNode<NavigationNode> newSiteT = siteListT.AddChild(newSite); NavigationNode userAdmin = new NavigationNode(); userAdmin.Key = "UserAdmin"; userAdmin.ParentKey = "SiteAdmin"; userAdmin.Controller = "UserAdmin"; userAdmin.Action = "Index"; userAdmin.Text = "UserManagement"; userAdmin.ViewRoles = "ServerAdmins"; userAdmin.ComponentVisibility = NamedNavigationFilters.Breadcrumbs + "," + NamedNavigationFilters.ChildTree; userAdmin.Url = userAdmin.ResolveUrl(); TreeNode<NavigationNode> userAdminT = adminRoot.AddChild(userAdmin); NavigationNode newUser = new NavigationNode(); newUser.Key = "UserEdit"; newUser.ParentKey = "UserAdmin"; newUser.Controller = "UserAdmin"; newUser.Action = "UserEdit"; newUser.Text = "NewUser"; newUser.ViewRoles = "Admins"; newUser.ComponentVisibility = NamedNavigationFilters.Breadcrumbs + "," + NamedNavigationFilters.ChildTree; newUser.Url = newUser.ResolveUrl(); TreeNode<NavigationNode> newUserT = userAdminT.AddChild(newUser); NavigationNode userSearch = new NavigationNode(); userSearch.Key = "UserSearch"; userSearch.ParentKey = "UserAdmin"; userSearch.Controller = "UserAdmin"; userSearch.Action = "Search"; userSearch.Text = "User Search"; userSearch.ViewRoles = "Admins"; userSearch.ComponentVisibility = NamedNavigationFilters.Breadcrumbs; userSearch.Url = userSearch.ResolveUrl(); TreeNode<NavigationNode> userSearchT = userAdminT.AddChild(userSearch); NavigationNode ipSearch = new NavigationNode(); ipSearch.Key = "IpSearch"; ipSearch.ParentKey = "UserAdmin"; ipSearch.Controller = "UserAdmin"; ipSearch.Action = "IpSearch"; ipSearch.Text = "IpSearch"; ipSearch.ViewRoles = "Admins"; ipSearch.ComponentVisibility = NamedNavigationFilters.Breadcrumbs; ipSearch.Url = ipSearch.ResolveUrl(); TreeNode<NavigationNode> ipSearchT = userAdminT.AddChild(ipSearch); NavigationNode roleAdmin = new NavigationNode(); roleAdmin.Key = "RoleAdmin"; roleAdmin.ParentKey = "SiteAdmin"; roleAdmin.Controller = "RoleAdmin"; roleAdmin.Action = "Index"; roleAdmin.Text = "RoleManagement"; roleAdmin.ViewRoles = "Admins"; roleAdmin.ComponentVisibility = NamedNavigationFilters.Breadcrumbs + "," + NamedNavigationFilters.ChildTree; roleAdmin.Url = roleAdmin.ResolveUrl(); TreeNode<NavigationNode> roleAdminT = adminRoot.AddChild(roleAdmin); // TODO: this one should not be in main or child menus // we can't have just one url since it depends on roleId // but we do want it to appear ar the active breadcrumb NavigationNode roleMembers = new NavigationNode(); roleMembers.Key = "RoleMembers"; roleMembers.ParentKey = "RoleAdmin"; roleMembers.Controller = "RoleAdmin"; roleMembers.Action = "RoleMembers"; roleMembers.Text = "RoleMembers"; roleMembers.ViewRoles = "Admins"; roleMembers.ComponentVisibility = NamedNavigationFilters.Breadcrumbs; roleMembers.Url = roleMembers.ResolveUrl(); roleMembers.PreservedRouteParameters = "roleId,pageNumber,pageSize"; TreeNode<NavigationNode> roleMembersT = roleAdminT.AddChild(roleMembers); NavigationNode roleEdit = new NavigationNode(); roleEdit.Key = "RoleEdit"; roleEdit.ParentKey = "RoleAdmin"; roleEdit.Controller = "RoleAdmin"; roleEdit.Action = "RoleEdit"; roleEdit.Text = "NewRole"; roleEdit.ViewRoles = "Admins"; roleEdit.ComponentVisibility = NamedNavigationFilters.Breadcrumbs + "," + NamedNavigationFilters.ChildTree; roleEdit.Url = roleEdit.ResolveUrl(); roleEdit.PreservedRouteParameters = "roleIde"; TreeNode<NavigationNode> roleEditT = roleAdminT.AddChild(roleEdit); NavigationNode coreData = new NavigationNode(); coreData.Key = "CoreData"; coreData.ParentKey = "SiteAdmin"; coreData.Controller = "CoreData"; coreData.Action = "Index"; coreData.Text = "CoreData"; coreData.ViewRoles = "ServerAdmins"; coreData.ComponentVisibility = NamedNavigationFilters.Breadcrumbs + "," + NamedNavigationFilters.ChildTree; coreData.Url = coreData.ResolveUrl(); TreeNode<NavigationNode> coreDataT = adminRoot.AddChild(coreData); NavigationNode currencyList = new NavigationNode(); currencyList.Key = "CurrencyList"; currencyList.ParentKey = "SiteAdmin"; currencyList.Controller = "CoreData"; currencyList.Action = "CurrencyList"; currencyList.Text = "CurrencyAdministration"; currencyList.ViewRoles = "ServerAdmins"; currencyList.ComponentVisibility = NamedNavigationFilters.Breadcrumbs + "," + NamedNavigationFilters.ChildTree; currencyList.Url = currencyList.ResolveUrl(); TreeNode<NavigationNode> currencyListT = coreDataT.AddChild(currencyList); //TODO: again I think we just want to be a breadcrumb here NavigationNode currencyEdit = new NavigationNode(); currencyEdit.Key = "CurrencyEdit"; currencyEdit.ParentKey = "CurrencyList"; currencyEdit.Controller = "CoreData"; currencyEdit.Action = "CurrencyEdit"; currencyEdit.Text = "NewCurrency"; currencyEdit.ViewRoles = "ServerAdmins"; currencyEdit.ComponentVisibility = NamedNavigationFilters.Breadcrumbs; currencyEdit.Url = currencyEdit.ResolveUrl(); currencyEdit.PreservedRouteParameters = "currencyGuid"; TreeNode<NavigationNode> currencyEditT = currencyListT.AddChild(currencyEdit); NavigationNode countryList = new NavigationNode(); countryList.Key = "CountryListPage"; countryList.ParentKey = "SiteAdmin"; countryList.Controller = "CoreData"; countryList.Action = "CountryListPage"; countryList.Text = "CountryStateAdministration"; countryList.ViewRoles = "ServerAdmins"; countryList.ComponentVisibility = NamedNavigationFilters.Breadcrumbs + "," + NamedNavigationFilters.ChildTree; countryList.Url = countryList.ResolveUrl(); TreeNode<NavigationNode> countryListT = coreDataT.AddChild(countryList); NavigationNode countryEdit = new NavigationNode(); countryEdit.Key = "CountryEdit"; countryEdit.ParentKey = "CountryListPage"; countryEdit.Controller = "CoreData"; countryEdit.Action = "CountryEdit"; countryEdit.Text = "NewCountry"; countryEdit.ViewRoles = "ServerAdmins"; countryEdit.ComponentVisibility = NamedNavigationFilters.Breadcrumbs + "," + NamedNavigationFilters.ChildTree; countryEdit.Url = countryEdit.ResolveUrl(); countryEdit.PreservedRouteParameters = "guid"; TreeNode<NavigationNode> countryEditT = countryListT.AddChild(countryEdit); NavigationNode stateList = new NavigationNode(); stateList.Key = "StateListPage"; stateList.ParentKey = "CountryListPage"; stateList.Controller = "CoreData"; stateList.Action = "StateListPage"; stateList.Text = "States"; stateList.ViewRoles = "ServerAdmins"; stateList.ComponentVisibility = NamedNavigationFilters.Breadcrumbs; stateList.Url = stateList.ResolveUrl(); stateList.PreservedRouteParameters = "countryGuid"; TreeNode<NavigationNode> stateListT = countryListT.AddChild(stateList); NavigationNode stateEdit = new NavigationNode(); stateEdit.Key = "StateEdit"; stateEdit.ParentKey = "StateListPage"; stateEdit.Controller = "CoreData"; stateEdit.Action = "StateEdit"; stateEdit.Text = "New State"; stateEdit.ViewRoles = "ServerAdmins"; stateEdit.ComponentVisibility = NamedNavigationFilters.Breadcrumbs; stateEdit.Url = stateEdit.ResolveUrl(); stateEdit.PreservedRouteParameters = "countryGuid"; TreeNode<NavigationNode> stateEditT = stateListT.AddChild(stateEdit); //string serialized = JsonConvert.SerializeObject(treeRoot,Formatting.Indented); return treeRoot; }