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, 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); }