public void BuildToolBar(ToolBarDefinition toolBarDefinition, IToolBar result)
        {
            var groups = _toolBarItemGroups
                         .Where(x => x.ToolBar == toolBarDefinition)
                         .OrderByDescending(x => x.SortOrder)
                         .ToList();

            for (var i = 0; i < groups.Count; i++)
            {
                var group        = groups[i];
                var toolBarItems = _toolBarItems
                                   .Where(x => x.Group == group)
                                   .OrderByDescending(x => x.SortOrder);

                foreach (var toolBarItem in toolBarItems)
                {
                    result.Add(new CommandToolBarItem(toolBarItem, _commandService.GetCommand(toolBarItem.CommandDefinition),
                                                      toolBarItem.CommandDefinition.Command, result));
                }

                if (i < groups.Count - 1 && toolBarItems.Any())
                {
                    result.Add(new ToolBarItemSeparator());
                }
            }
        }
		public void BuildToolBar(ToolBarDefinition toolBarDefinition, IToolBar result)
		{
			var groups = _toolBarItemGroups
				.Where(x => x.ToolBar == toolBarDefinition)
				.OrderByDescending(x => x.SortOrder)
				.ToList();

			for (var i = 0; i < groups.Count; i++)
			{
				var group = groups[i];
				var toolBarItems = _toolBarItems
					.Where(x => x.Group == group)
					.OrderByDescending(x => x.SortOrder);

				foreach (var toolBarItem in toolBarItems)
					result.Add(new CommandToolBarItem(toolBarItem, _commandService.GetCommand(toolBarItem.CommandDefinition),
						toolBarItem.CommandDefinition.Command, result));

				if (i < groups.Count - 1 && toolBarItems.Any())
					result.Add(new ToolBarItemSeparator());
			}
		}