private void LoadCommandPlugins() { var formatter = new MenuFormatter(); var pluginManager = new CommandPluginManager(); try { pluginManager.LoadAllPlugins(Path.Combine(AssemblyDirectory, "Plugins")); var plugins = pluginManager.GetPluginInstances(); // Add config plugin since it is a shared plugin SetupConfigurationPlugin(plugins); foreach (var plugin in plugins) { plugin.Init(_provider4); _provider4.AddGlobalCommand(plugin); } var menuGroups = formatter.GetMenuGroups(plugins); formatter.ConfigureMenu(menuGroups, _provider4); } catch (Exception ex) { MessageBox.Show(ex.ToString()); throw; } }
public void ShouldGroupMenuItemsByName() { var plugins = new List <CommandPluginBase>(); plugins.Add(new MockCommandPlugin("A", "HOME")); plugins.Add(new MockCommandPlugin("B", "HOME")); plugins.Add(new MockCommandPlugin("C", "HOME")); plugins.Add(new MockCommandPlugin("D", "UTILS")); plugins.Add(new MockCommandPlugin("E", "UTILS")); var groups = formatter.GetMenuGroups(plugins.Select(p => new CommandPluginWrapper(p))); Assert.That(groups.Keys.Count, Is.EqualTo(2)); var home = groups["HOME"]; Assert.That(home.Count, Is.EqualTo(3)); var utils = groups["UTILS"]; Assert.That(utils.Count(), Is.EqualTo(2)); }