Exemplo n.º 1
0
        public IEnumerable <GroupedButton> LoadButtons(ControllerContext controllerContext, string position = null)
        {
            var matchedButtonPlugins = MatchButtonPlugins(controllerContext.RouteData, position);

            var matchButtonGroups = MatchButtonGroups(controllerContext.RouteData, position);

            var groupedList = new List <GroupedButton>();

            foreach (var group in matchButtonGroups)
            {
                var buttonsInGroup = matchedButtonPlugins
                                     .Where(it => !string.IsNullOrEmpty(it.GroupName) && it.GroupName.EqualsOrNullEmpty(group.Name, StringComparison.OrdinalIgnoreCase))
                                     .OrderBy(it => it.Order)
                                     .ToArray();

                var groupedButton = new GroupedButton(group, buttonsInGroup);

                groupedList.Add(groupedButton);
            }

            groupedList.AddRange(matchedButtonPlugins.Where(it => string.IsNullOrEmpty(it.GroupName)).Select(it => new GroupedButton(it, null)));

            return(groupedList.OrderBy(it => it.Group.Order).ToArray());
        }
        public IEnumerable<GroupedButton> LoadButtons(ControllerContext controllerContext, string position = null)
        {
            var matchedButtonPlugins = MatchButtonPlugins(controllerContext.RouteData, position);

            var matchButtonGroups = MatchButtonGroups(controllerContext.RouteData, position);

            var groupedList = new List<GroupedButton>();

            foreach (var group in matchButtonGroups)
            {
                var buttonsInGroup = matchedButtonPlugins
                    .Where(it => !string.IsNullOrEmpty(it.GroupName) && it.GroupName.EqualsOrNullEmpty(group.Name, StringComparison.OrdinalIgnoreCase))
                    .OrderBy(it => it.Order)
                    .ToArray();

                var groupedButton = new GroupedButton(group, buttonsInGroup);

                groupedList.Add(groupedButton);
            }

            groupedList.AddRange(matchedButtonPlugins.Where(it => string.IsNullOrEmpty(it.GroupName)).Select(it => new GroupedButton(it, null)));

            return groupedList.OrderBy(it => it.Group.Order).ToArray();
        }