private NavigationNodeWithParent ConvertMvc(Type type, MethodInfo method,
                                                    NavNodeAttribute attribute,
                                                    NavNodeControllerAttribute controllerAttr,
                                                    AreaAttribute areaAttr)
        {
            var node   = Convert(attribute);
            var prefix = "";

            if (controllerAttr != null)
            {
                prefix = controllerAttr.KeyPrefix;
            }
            node.Key = attribute.Key;
            if (string.IsNullOrEmpty(node.Key))
            {
                node.Key = Guid.NewGuid().ToString();
            }
            if (!string.IsNullOrEmpty(node.Key) && node.Key.StartsWith("{Prefix}"))
            {
                node.Key = prefix + node.Key.Substring("{Prefix}".Length);
            }
            var parentKey = attribute.ParentKey;

            if (!string.IsNullOrEmpty(parentKey) && parentKey.StartsWith("{Prefix}"))
            {
                parentKey = prefix + parentKey.Substring("{Prefix}".Length);
            }

            node.Area = string.Empty;
            if (areaAttr != null)
            {
                node.Area = areaAttr.RouteValue;
            }
            if (!string.IsNullOrEmpty(attribute.Area))
            {
                node.Area = attribute.Area;
            }

            if (!string.IsNullOrEmpty(attribute.Url))
            {
                node.Url = attribute.Url;
            }
            else
            {
                node.Controller = type.Name.Substring(0, type.Name.IndexOf("Controller"));

                node.Action = method.Name;
                var actioNameAttr = method.GetCustomAttributes(typeof(ActionNameAttribute), true)
                                    .FirstOrDefault() as ActionNameAttribute;
                if (actioNameAttr != null)
                {
                    node.Action = actioNameAttr.Name;
                }
            }
            return(new NavigationNodeWithParent()
            {
                Node = node, ParentKey = parentKey
            });
        }
        //private NavigationNodeWithParent ConvertRazorPage(Type type,
        //    NavNodeAttribute attribute,
        //    AreaAttribute areaAttr)
        //{
        //    var node = Convert(attribute);
        //    node.Key = attribute.Key;
        //    if (string.IsNullOrEmpty(node.Key))
        //    {
        //        node.Key = Guid.NewGuid().ToString();
        //    }
        //    var parentKey = attribute.ParentKey;

        //    node.Area = string.Empty;
        //    if (areaAttr != null)
        //    {
        //        node.Area = areaAttr.RouteValue;
        //    }
        //    if (!string.IsNullOrEmpty(attribute.Area))
        //    {
        //        node.Area = attribute.Area;
        //    }

        //    if (!string.IsNullOrEmpty(attribute.Url))
        //    {
        //        node.Url = attribute.Url;
        //    }
        //    else
        //    {
        //        node.Page = attribute.Page;
        //    }
        //    return new NavigationNodeWithParent() { Node = node, ParentKey = parentKey };
        //}


        private NavigationNode Convert(NavNodeAttribute attribute)
        {
            var node = new NavigationNode();

            if (attribute.ResourceType == null)
            {
                node.Text            = attribute.Text ?? string.Empty;
                node.Title           = attribute.Title ?? string.Empty;
                node.MenuDescription = attribute.MenuDescription ?? string.Empty;
            }
            else
            {
                node.Text            = GetResourceString(attribute.ResourceType, attribute.Text);
                node.Title           = GetResourceString(attribute.ResourceType, attribute.Title);
                node.MenuDescription = GetResourceString(attribute.ResourceType, attribute.MenuDescription);
            }
            node.NamedRoute = attribute.NamedRoute ?? string.Empty;
            node.ExcludeFromSearchSiteMap = attribute.ExcludeFromSearchSiteMap;
            node.HideFromAuthenticated    = attribute.HideFromAuthenticated;
            node.HideFromAnonymous        = attribute.HideFromAnonymous;
            node.PreservedRouteParameters = attribute.PreservedRouteParameters ?? string.Empty;
            node.ComponentVisibility      = attribute.ComponentVisibility ?? string.Empty;
            node.AuthorizationPolicy      = attribute.AuthorizationPolicy ?? string.Empty;
            node.ViewRoles    = attribute.ViewRoles ?? string.Empty;
            node.CustomData   = attribute.CustomData ?? string.Empty;
            node.IsClickable  = attribute.IsClickable;
            node.IconCssClass = attribute.IconCssClass ?? string.Empty;
            node.CssClass     = attribute.CssClass ?? string.Empty;
            node.Target       = attribute.Target ?? string.Empty;
            node.Order        = attribute.Order;
            if (!string.IsNullOrEmpty(attribute.DataAttributesJson))
            {
                var list = new List <DataAttribute>();
                try
                {
                    var dict = JsonConvert.DeserializeObject <Dictionary <string, object> >
                                   (attribute.DataAttributesJson);
                    foreach (var key in dict.Keys)
                    {
                        var value = dict[key];
                        if (value != null)
                        {
                            var da = new DataAttribute();
                            da.Attribute = key;
                            da.Value     = dict[key].ToString();
                            list.Add(da);
                        }
                    }
                }
                catch
                {
                }
                node.DataAttributes = list;
            }

            return(node);
        }