public IEnumerable<MenuItem> Filter(IEnumerable<MenuItem> items)
        {
            foreach (var item in items) {
                if (item.Content != null && item.Content.ContentItem.ContentType == "NavigationTagsMenuItem") {

                    var tags = GetTags();

                    var menuPosition = item.Position;
                    int index = 0;
                    foreach (var tag in tags) {
                        var inserted = new MenuItem {
                            Text = new LocalizedString(tag.TagName),
                            Url = string.Format("~/tags/{0}", tag.TagName.ToLowerInvariant()),
                            Items = new MenuItem[0],
                            Position = menuPosition + ":" + index++,
                        };

                        yield return inserted;
                    }
                }
                else {
                    yield return item;
                }
            }
        }
 public void NullRouteValuesShouldNotEqualEmptyRouteValues() {
     var item1 = new MenuItem { Text = "hello" };
     var item2 = new MenuItem { Text = "hello" };
     var item3 = new MenuItem { Text = "hello", RouteValues = new RouteValueDictionary() };
     var item4 = new MenuItem { Text = "hello", RouteValues = new RouteValueDictionary() };
     AssertSameSameDifferent(item1, item2, item3);
     AssertSameSameDifferent(item3, item4, item1);
 }
 public void NullRouteValuesShouldEqualEmptyRouteValues() {
     var item1 = new MenuItem { Text = new LocalizedString("hello") };
     var item2 = new MenuItem { Text = new LocalizedString("hello") };
     var item3 = new MenuItem { Text = new LocalizedString("hello"), RouteValues = new RouteValueDictionary() };
     var item4 = new MenuItem { Text = new LocalizedString("hello"), RouteValues = new RouteValueDictionary() };
     AssertSameSameSame(item1, item2, item3);
     AssertSameSameSame(item3, item4, item1);
 }
Esempio n. 4
0
 private static bool PositionHasMajorNumber(MenuItem mi, int? position = null) {
     int menuPosition;
     var major = mi.Position == null ? null : mi.Position.Split('.')[0];
     if (string.IsNullOrEmpty(major)) {
         return false;
     }
     var parsed = int.TryParse(major, out menuPosition);
     return parsed && (!position.HasValue || position.Value == menuPosition);
 }
        private static void AssertSameSameSame(MenuItem item1, MenuItem item2, MenuItem item3) {
            var comparer = new MenuItemComparer();

            Assert.That(comparer.Equals(item1, item2), Is.True);
            Assert.That(comparer.Equals(item1, item3), Is.True);
            Assert.That(comparer.Equals(item2, item3), Is.True);

            Assert.That(comparer.GetHashCode(item1), Is.EqualTo(comparer.GetHashCode(item2)));
            Assert.That(comparer.GetHashCode(item1), Is.EqualTo(comparer.GetHashCode(item3)));
            Assert.That(comparer.GetHashCode(item2), Is.EqualTo(comparer.GetHashCode(item3)));
        }
        private static void AssertSameSameDifferent(MenuItem item1, MenuItem item2, MenuItem item3) {
            var comparer = new MenuItemComparer();

            Assert.That(comparer.Equals(item1, item2), Is.True);
            Assert.That(comparer.Equals(item1, item3), Is.False);
            Assert.That(comparer.Equals(item2, item3), Is.False);

            Assert.That(comparer.GetHashCode(item1), Is.EqualTo(comparer.GetHashCode(item2)));
            // - hash inequality isn't really guaranteed, now that you mention it
            //Assert.That(comparer.GetHashCode(item1), Is.Not.EqualTo(comparer.GetHashCode(item3)));
            //Assert.That(comparer.GetHashCode(item2), Is.Not.EqualTo(comparer.GetHashCode(item3)));
        }
        public IEnumerable<MenuItem> Filter(IEnumerable<MenuItem> items) {

            foreach (var item in items) {
                if (item.Content != null && item.Content.ContentItem.ContentType == "TaxonomyNavigationMenuItem") {
                    // expand query

                    var taxonomyNavigationPart = item.Content.As<TaxonomyNavigationPart>();

                    var rootTerm = _taxonomyService.GetTerm(taxonomyNavigationPart.TermId);

                    var allTerms = rootTerm != null
                                       ? _taxonomyService.GetChildren(rootTerm).ToArray()
                                       : _taxonomyService.GetTerms(taxonomyNavigationPart.TaxonomyId).ToArray();

                    var menuPosition = item.Position;
                    var rootPath = rootTerm == null ? "" : rootTerm.FullPath;

                    foreach (var contentItem in allTerms) {
                        if (contentItem != null) {
                            var part = contentItem;

                            var menuText = _contentManager.GetItemMetadata(part).DisplayText;
                            var routes = _contentManager.GetItemMetadata(part).DisplayRouteValues;

                            var positions = contentItem.FullPath.Substring(rootPath.Length).Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Select(x => allTerms.First(t => t.Id == Int32.Parse(x)).Weight).ToArray();

                            var inserted = new MenuItem {
                                Text = new LocalizedString(menuText),
                                IdHint = item.IdHint,
                                Classes = item.Classes,
                                Url = item.Url,
                                Href = item.Href,
                                LinkToFirstChild = false,
                                RouteValues = routes,
                                LocalNav = item.LocalNav,
                                Items = new MenuItem[0],
                                Position = menuPosition + ":" + String.Join(".", positions.Select(x => x.ToString()).ToArray()),
                                Permissions = item.Permissions,
                                Content = part
                            };

                            yield return inserted;
                        }
                    }
                }
                else {
                    yield return item;
                }
            }
        }
        static MenuItem Join(IEnumerable<MenuItem> items)
        {
            if (items.Count() < 2)
                return items.Single();

            var joined = new MenuItem {
                Text = items.First().Text,
                Url = items.First().Url,
                Href = items.First().Href,
                RouteValues = items.First().RouteValues,
                Items = Merge(items.Select(x => x.Items)).ToArray(),
                Position = SelectBestPositionValue(items.Select(x => x.Position)),
                Permissions = items.SelectMany(x => x.Permissions)
            };
            return joined;
        }
Esempio n. 9
0
        public static MenuItem GetParent(IEnumerable<MenuItem> menuItems, MenuItem child, MenuItem currentParent = null) {
            if (menuItems == null || child == null) {
                return null;
            }

            foreach (var menuItem in menuItems) {
                if (menuItem == child)
                    return currentParent;

                var item = GetParent(menuItem.Items, child, menuItem);
                if (item != null)
                    return item;
                    
            }
            return null;
        }
        public IEnumerable<MenuItem> Filter(IEnumerable<MenuItem> items) {

            foreach (var item in items) {
                if (item.Content != null && item.Content.ContentItem.ContentType == "TaxonomyNavigationMenuItem") {
                    // expand query

                    var taxonomyNavigationPart = item.Content.As<TaxonomyNavigationPart>();

                    var rootTerm = _taxonomyService.GetTerm(taxonomyNavigationPart.TermId);

                    var allTerms = rootTerm != null
                                       ? _taxonomyService.GetChildren(rootTerm)
                                       : _taxonomyService.GetTerms(taxonomyNavigationPart.TaxonomyId);

                    var menuPosition = item.Position;
                    foreach (var contentItem in allTerms) {
                        if (contentItem != null) {
                            var part = contentItem;

                            var menuText = _contentManager.GetItemMetadata(part).DisplayText;
                            var routes = _contentManager.GetItemMetadata(part).DisplayRouteValues;

                            var inserted = new MenuItem {
                                Text = new LocalizedString(menuText),
                                IdHint = item.IdHint,
                                Classes = item.Classes,
                                Url = item.Url,
                                Href = item.Href,
                                LinkToFirstChild = false,
                                RouteValues = routes,
                                LocalNav = item.LocalNav,
                                Items = new MenuItem[0],
                                Position = menuPosition + contentItem.Path.TrimEnd('/').Replace("/", "."),
                                Permissions = item.Permissions,
                                Content = part
                            };

                            yield return inserted;
                        }
                    }
                }
                else {
                    yield return item;
                }
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Builds a local menu item shape.
        /// </summary>
        /// <param name="shapeFactory">The shape factory.</param>
        /// <param name="parentShape">The parent shape.</param>
        /// <param name="menu">The menu shape.</param>
        /// <param name="menuItem">The menu item to build the shape for.</param>
        /// <returns>The menu item shape.</returns>
        public static dynamic BuildLocalMenuItemShape(dynamic shapeFactory, dynamic parentShape, dynamic menu, MenuItem menuItem)
        {
            var menuItemShape = shapeFactory.LocalMenuItem()
                .Text(menuItem.Text)
                .IdHint(menuItem.IdHint)
                .Href(menuItem.Href)
                .LinkToFirstChild(menuItem.LinkToFirstChild)
                .LocalNav(menuItem.LocalNav)
                .Selected(menuItem.Selected)
                .RouteValues(menuItem.RouteValues)
                .Item(menuItem)
                .Menu(menu)
                .Parent(parentShape);

            foreach (var className in menuItem.Classes)
                menuItemShape.Classes.Add(className);

            return menuItemShape;
        }
Esempio n. 12
0
        public IEnumerable<MenuItem> Filter(IEnumerable<MenuItem> items) {

            foreach (var item in items) {
                if (item.Content != null && item.Content.ContentItem.ContentType == "NavigationQueryMenuItem") {
                    // expand query
                    var navigationQuery = item.Content.As<NavigationQueryPart>();
                    var contentItems = _projectionManager.GetContentItems(navigationQuery.QueryPartRecord.Id, navigationQuery.Skip, navigationQuery.Items).ToList();

                    var menuPosition = item.Position;
                    int index = 0;
                    foreach (var contentItem in contentItems) {
                        if (contentItem != null) {
                            var part = contentItem;

                            var menuText = _contentManager.GetItemMetadata(part).DisplayText;
                            var routes = _contentManager.GetItemMetadata(part).DisplayRouteValues;

                            var inserted = new MenuItem {
                                Text = new LocalizedString(menuText),
                                IdHint = item.IdHint,
                                Classes = item.Classes,
                                Url = item.Url,
                                Href = item.Href,
                                LinkToFirstChild = false,
                                RouteValues = routes,
                                LocalNav = item.LocalNav,
                                Items = new MenuItem[0],
                                Position = menuPosition + ":" + index++,
                                Permissions = item.Permissions,
                                Content = part
                            };

                            yield return inserted;
                        }
                    }
                }
                else {
                    yield return item;
                }
            }
        }
Esempio n. 13
0
 public void ValuesShouldMismatch() {
     var item1 = new MenuItem { Text = new LocalizedString("hello"), RouteValues = new RouteValueDictionary(new { one = "1", two = "2" }) };
     var item2 = new MenuItem { Text = new LocalizedString("hello"), RouteValues = new RouteValueDictionary(new { one = "1", two = "2" }) };
     var item3 = new MenuItem { Text = new LocalizedString("hello"), RouteValues = new RouteValueDictionary(new { one = "1", two = "3" }) };
     AssertSameSameDifferent(item1, item2, item3);
 }
Esempio n. 14
0
 public void AdditionalPropertiesShouldMismatch() {
     var item1 = new MenuItem { Text = new LocalizedString("hello"), RouteValues = new RouteValueDictionary(new { one = 1 }) };
     var item2 = new MenuItem { Text = new LocalizedString("hello"), RouteValues = new RouteValueDictionary(new { one = 1 }) };
     var item3 = new MenuItem { Text = new LocalizedString("hello"), RouteValues = new RouteValueDictionary(new { one = 1, two = 2 }) };
     AssertSameSameDifferent(item1, item2, item3);
 }
 public void ValueTypeShouldMismatch() {
     var item1 = new MenuItem { Text = "hello", RouteValues = new RouteValueDictionary(new { one = 1 }) };
     var item2 = new MenuItem { Text = "hello", RouteValues = new RouteValueDictionary(new { one = 1 }) };
     var item3 = new MenuItem { Text = "hello", RouteValues = new RouteValueDictionary(new { one = "1" }) };
     AssertSameSameDifferent(item1, item2, item3);
 }
 public NavigationBuilder Remove(MenuItem item) {
     Contained.Remove(item);
     return this;
 }
 private void PopulateContentItems(TermPart part, MenuItem parentMenu)
 {
     var contentItems = _taxonomyService.GetContentItems(part);
     int menuPositionIndex = 1;
     var contentMenuItems = (from item in contentItems
                             let menuText = _contentManager.GetItemMetadata(item).DisplayText
                             let routes = _contentManager.GetItemMetadata(item).DisplayRouteValues
                             select new MenuItem
                             {
                                 Text = new LocalizedString(menuText),
                                 LinkToFirstChild = false,
                                 RouteValues = routes,
                                 LocalNav = true,
                                 Items = new MenuItem[0],
                                 Position = parentMenu.Position + "." + (menuPositionIndex++),
                                 Content = item
                             }).ToList();
     parentMenu.Items = contentMenuItems;
 }
Esempio n. 18
0
        static MenuItem Join(IEnumerable<MenuItem> items) {
            var list = items.ToArray();

            if (list.Count() < 2)
                return list.Single();

            var joined = new MenuItem {
                Text = list.First().Text,
                IdHint = list.Select(x => x.IdHint).FirstOrDefault(x => !string.IsNullOrWhiteSpace(x)),
                Classes = list.Select(x => x.Classes).FirstOrDefault(x => x != null && x.Count > 0),
                Url = list.Select(x => x.Url).FirstOrDefault(x => !string.IsNullOrWhiteSpace(x)),
                Href = list.Select(x => x.Href).FirstOrDefault(x => !string.IsNullOrWhiteSpace(x)),
                LinkToFirstChild = list.First().LinkToFirstChild,
                RouteValues = list.Select(x => x.RouteValues).FirstOrDefault(x => x != null),
                LocalNav = list.Any(x => x.LocalNav),
                Culture = list.First().Culture,
                Items = Merge(list.Select(x => x.Items)).ToArray(),
                Position = SelectBestPositionValue(list.Select(x => x.Position)),
                Permissions = list.SelectMany(x => x.Permissions).Distinct(),
                Content = list.First().Content
            };

            return joined;
        }
Esempio n. 19
0
        public IEnumerable<MenuItem> Filter(IEnumerable<MenuItem> items) {

            foreach (var item in items) {
                if (item.Content != null && item.Content.ContentItem.ContentType == "TaxonomyNavigationMenuItem") {
                    // expand query

                    var taxonomyNavigationPart = item.Content.As<TaxonomyNavigationPart>();

                    var rootTerm = _taxonomyService.GetTerm(taxonomyNavigationPart.TermId);

                    List<int> positionList = new List<int>();

                    var allTerms = rootTerm != null
                                       ? _taxonomyService.GetChildren(rootTerm).ToArray()
                                       : _taxonomyService.GetTerms(taxonomyNavigationPart.TaxonomyId).ToArray();

                    var rootlevel = rootTerm == null ? 0 : rootTerm.GetLevels();
                    
                    positionList.Add(0);

                    var menuPosition = item.Position;
                    int parentLevel = rootlevel;

                    foreach (var contentItem in allTerms) {
                        if (contentItem != null) {
                            var part = contentItem;

                            if (taxonomyNavigationPart.HideEmptyTerms == true && part.Count == 0) {
                                continue;
                            }
                            string termPosition = "";
                            if (part.GetLevels() - rootlevel > parentLevel) {
                                positionList.Add(0);
                                parentLevel = positionList.Count - 1;
                            }
                            else
                                if ((part.GetLevels() - rootlevel) == parentLevel) {
                                    positionList[parentLevel]++;
                                }
                                else {
                                    positionList.RemoveRange(1, positionList.Count - 1);
                                    parentLevel = positionList.Count - 1;
                                    positionList[parentLevel]++;
                                }

                            termPosition = positionList.First().ToString();
                            foreach (var position in positionList.Skip(1)) {
                                termPosition = termPosition + "." + position.ToString();
                            }


                            var menuText = _contentManager.GetItemMetadata(part).DisplayText;
                            var routes = _contentManager.GetItemMetadata(part).DisplayRouteValues;

                            if (taxonomyNavigationPart.DisplayContentCount) {
                                menuText = String.Format(menuText + " ({0})", part.Count.ToString());
                            }

                            var inserted = new MenuItem {
                                Text = new LocalizedString(menuText),
                                IdHint = item.IdHint,
                                Classes = item.Classes,
                                Url = item.Url,
                                Href = item.Href,
                                LinkToFirstChild = false,
                                RouteValues = routes,
                                LocalNav = item.LocalNav,
                                Items = new MenuItem[0],
                                Position = menuPosition + ":" + termPosition,
                                Permissions = item.Permissions,
                                Content = part
                            };

                            yield return inserted;
                        }
                    }
                }
                else {
                    yield return item;
                }
            }
        }
Esempio n. 20
0
 private static bool PositionHasMojorNumber(MenuItem mi)
 {
     int foo;
     var major = mi.Position.Split('.')[0];
     return !string.IsNullOrEmpty(major) && int.TryParse(major, out foo);
 }
Esempio n. 21
0
 public void PositionAndChildrenDontMatter() {
     var item1 = new MenuItem { Text = new LocalizedString("hello"), RouteValues = new RouteValueDictionary(new { one = "1", two = "2" }) };
     var item2 = new MenuItem { Text = new LocalizedString("hello"), RouteValues = new RouteValueDictionary(new { one = "1", two = "2" }), Position = "4.0" };
     var item3 = new MenuItem { Text = new LocalizedString("hello"), RouteValues = new RouteValueDictionary(new { one = "1", two = "2" }), Items = new[] { new MenuItem() } };
     AssertSameSameSame(item1, item2, item3);
 }
Esempio n. 22
0
        public IEnumerable<MenuItem> Filter(IEnumerable<MenuItem> items) {

            foreach (var item in items) {
                if (item.Content != null && item.Content.ContentItem.ContentType == "TaxonomyNavigationMenuItem") {

                    var taxonomyNavigationPart = item.Content.As<TaxonomyNavigationPart>();

                    var rootTerm = _taxonomyService.GetTerm(taxonomyNavigationPart.TermId);

                    TermPart[] allTerms;

                    if (rootTerm != null) {
                        // if DisplayRootTerm is specified add it to the menu items to render
                        allTerms = _taxonomyService.GetChildren(rootTerm, taxonomyNavigationPart.DisplayRootTerm).ToArray();
                    }
                    else {
                        allTerms = _taxonomyService.GetTerms(taxonomyNavigationPart.TaxonomyId).ToArray();
                    }

                    var rootLevel = rootTerm != null
                        ? rootTerm.GetLevels()
                        : 0;

                    var menuPosition = item.Position;
                    var rootPath = rootTerm == null || taxonomyNavigationPart.DisplayRootTerm ? "" : rootTerm.FullPath;

                    var startLevel = rootLevel + 1;
                    if (rootTerm == null || taxonomyNavigationPart.DisplayRootTerm) {
                        startLevel = rootLevel;
                    }

                    var endLevel = Int32.MaxValue;
                    if (taxonomyNavigationPart.LevelsToDisplay > 0) {
                        endLevel = startLevel + taxonomyNavigationPart.LevelsToDisplay - 1;
                    }

                    foreach (var contentItem in allTerms) {
                        if (contentItem != null) {
                            var part = contentItem;
                            var level = part.GetLevels();

                            // filter levels ?
                            if (level < startLevel || level > endLevel) {
                                continue;
                            }

                            // ignore menu item if there are no content items associated to the term
                            if (taxonomyNavigationPart.HideEmptyTerms && part.Count == 0) {
                                continue;
                            }

                            var menuText = _contentManager.GetItemMetadata(part).DisplayText;
                            var routes = _contentManager.GetItemMetadata(part).DisplayRouteValues;

                            if (taxonomyNavigationPart.DisplayContentCount) {
                                menuText += " (" + part.Count + ")";
                            }

                            // create 
                            var positions = contentItem.FullPath.Substring(rootPath.Length)
                                .Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries)
                                .Select(p => Array.FindIndex(allTerms, t => t.Id == Int32.Parse(p)))
                                .ToArray();

                            var inserted = new MenuItem {
                                Text = new LocalizedString(menuText),
                                IdHint = item.IdHint,
                                Classes = item.Classes,
                                Url = item.Url,
                                Href = item.Href,
                                LinkToFirstChild = false,
                                RouteValues = routes,
                                LocalNav = item.LocalNav,
                                Items = new MenuItem[0],
                                Position = menuPosition + ":" + String.Join(".", positions.Select(x => x.ToString(CultureInfo.InvariantCulture)).ToArray()),
                                Permissions = item.Permissions,
                                Content = part
                            };

                            yield return inserted;
                        }
                    }
                }
                else {
                    yield return item;
                }
            }
        }
Esempio n. 23
0
        public IEnumerable<MenuItem> Filter(IEnumerable<MenuItem> items) {
            foreach (var item in items) {
                if (item.Content != null && item.Content.ContentItem.ContentType == "AliasBreadcrumbMenuItem") {
                    var request = _hca.Current().Request;
                    var path = request.Path;
                    var appPath = request.ApplicationPath ?? "/";
                    var requestUrl = (path.StartsWith(appPath) ? path.Substring(appPath.Length) : path).TrimStart('/');
                    var endsWithSlash = requestUrl.EndsWith("/");

                    var menuPosition = item.Position;

                    var urlLevel = endsWithSlash ? requestUrl.Count(l => l == '/') - 1 : requestUrl.Count(l => l == '/');
                    var menuLevel = menuPosition.Count(l => l == '.');

                    // Checking menu item if it's the leaf element or it's an intermediate element
                    // or it's an unneccessary element according to the url.
                    RouteValueDictionary contentRoute;
                    if (menuLevel == urlLevel) {
                        contentRoute = request.RequestContext.RouteData.Values;
                    }
                    else {
                        // If menuLevel doesn't equal with urlLevel it can mean that this menu item is
                        // an intermediate element (the difference is a positive value) or this menu
                        // item is lower in the navigation hierarchy according to the url (negative
                        // value). If the value is negative, removing the menu item, if the value
                        // is positive finding its place in the hierarchy.
                        var levelDifference = urlLevel - menuLevel;
                        if (levelDifference > 0) {
                            if (endsWithSlash) {
                                levelDifference += levelDifference;
                            }
                            for (int i = 0; i < levelDifference; i++) {
                                requestUrl = requestUrl.Remove(requestUrl.LastIndexOf('/'));
                                path = path.Remove(path.LastIndexOf('/'));
                            }
                            contentRoute = _aliasService.Get(requestUrl);
                            if (contentRoute == null) {
                                // After the exact number of segments is cut out from the url and the
                                // currentRoute is still null, trying another check with the added slash,
                                // because we don't know if the alias was created with a slash at the end or not.
                                contentRoute = _aliasService.Get(requestUrl.Insert(requestUrl.Length, "/"));
                                path = path.Insert(path.Length, "/");
                                if (contentRoute == null) {
                                    contentRoute = new RouteValueDictionary();
                                }
                            }
                        }
                        else {
                            contentRoute = new RouteValueDictionary();
                        }
                    }

                    object id;
                    contentRoute.TryGetValue("Id", out id);
                    int contentId;
                    int.TryParse(id as string, out contentId);
                    if (contentId == 0) {
                        // If failed to get the Id's value from currentRoute, transform the alias to the virtual path
                        // and try to get the content item's id from there. E.g. "Blogs/Blog/Item?blogId=12" where
                        // the last digits represents the content item's id. If there is a match in the path we get
                        // the digits after the equality sign.
                        // There is an another type of the routes: like "Contents/Item/Display/13", but when the
                        // content item's route is in this form we already have the id from contentRoute.TryGetValue("Id", out id).
                        var virtualPath = _aliasService.LookupVirtualPaths(contentRoute, _hca.Current()).FirstOrDefault();
                        int.TryParse(virtualPath != null ? virtualPath.VirtualPath.Substring(virtualPath.VirtualPath.LastIndexOf('=') + 1) : "0", out contentId);
                    }
                    if (contentId != 0) {
                        var currentContentItem = _contentManager.Get(contentId);
                        if (currentContentItem != null) {
                            var menuText = _contentManager.GetItemMetadata(currentContentItem).DisplayText;
                            var routes = _contentManager.GetItemMetadata(currentContentItem).DisplayRouteValues;

                            var inserted = new MenuItem {
                                Text = new LocalizedString(menuText),
                                IdHint = item.IdHint,
                                Classes = item.Classes,
                                Url = path,
                                Href = item.Href,
                                LinkToFirstChild = false,
                                RouteValues = routes,
                                LocalNav = item.LocalNav,
                                Items = Enumerable.Empty<MenuItem>(),
                                Position = menuPosition,
                                Permissions = item.Permissions,
                                Content = item.Content
                            };

                            yield return inserted;
                        }
                    }
                }
                else {
                    yield return item;
                }
            }
        }
Esempio n. 24
0
 public MenuHierarchy(MenuItem item)
 {
     Item = item;
     Children = new List<MenuHierarchy>();
 }
Esempio n. 25
0
 public NavigationItemBuilder() {
     _item = new MenuItem();
 }
Esempio n. 26
0
        private static RouteData GetRouteData(MenuItem menuItem) {
            RouteData routeData = new RouteData();
            routeData.Values["area"] = menuItem.RouteValues["area"];
            routeData.Values["controller"] = menuItem.RouteValues["controller"];
            routeData.Values["action"] = menuItem.RouteValues["action"];

            return routeData;
        }
Esempio n. 27
0
 public void TextShouldCauseDifferenceAndNullRouteValuesAreEqual() {
     var item1 = new MenuItem { Text = new LocalizedString("hello") };
     var item2 = new MenuItem { Text = new LocalizedString("hello") };
     var item3 = new MenuItem { Text = new LocalizedString("hello3") };
     AssertSameSameDifferent(item1, item2, item3);
 }
Esempio n. 28
0
        /// <summary>
        /// Builds a local menu item shape.
        /// </summary>
        /// <param name="shapeFactory">The shape factory.</param>
        /// <param name="parentShape">The parent shape.</param>
        /// <param name="menu">The menu shape.</param>
        /// <param name="menuItem">The menu item to build the shape for.</param>
        /// <returns>The menu item shape.</returns>
        public static dynamic BuildLocalMenuItemShape(dynamic shapeFactory, dynamic parentShape, dynamic menu, MenuItem menuItem)
        {
            var menuItemShape = shapeFactory.LocalMenuItem()
                                .Text(menuItem.Text)
                                .IdHint(menuItem.IdHint)
                                .Url(menuItem.Url)
                                .Href(menuItem.Href)
                                .LinkToFirstChild(menuItem.LinkToFirstChild)
                                .LocalNav(menuItem.LocalNav)
                                .Selected(menuItem.Selected)
                                .RouteValues(menuItem.RouteValues)
                                .Item(menuItem)
                                .Menu(menu)
                                .Parent(parentShape);

            foreach (var className in menuItem.Classes)
            {
                menuItemShape.Classes.Add(className);
            }

            return(menuItemShape);
        }