private void AddCommand(MenuCommand commandItem) { if (commandService != null && commandItem != null && commandService.FindCommand(commandItem.CommandID) == null) { commandService.AddCommand(commandItem); } }
/// <summary> /// Changes the contest chosen by user. /// </summary> /// <param name="newContest">New contest id (in recentContests).</param> private void ChangeContest(int newContest) { if (newContest > 0) { Contest temp = recentContests[0]; recentContests[0] = recentContests[newContest]; for (; newContest > 1 && recentContests[newContest - 1].id < temp.id; newContest--) { recentContests[newContest] = recentContests[newContest - 1]; } for (; newContest < 5 && recentContests[newContest + 1].id > temp.id; newContest++) { recentContests[newContest] = recentContests[newContest + 1]; } recentContests[newContest] = temp; } OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; for (uint i = PkgCmdIDList.cmdidContestOption1Command; i <= PkgCmdIDList.cmdidContestOption6Command; i++) { CommandID cmdID = new CommandID(GuidList.guidCF_TesterCmdSet, (int)i); OleMenuCommand mc = (OleMenuCommand)mcs.FindCommand(cmdID); mc.Text = "#" + recentContests[(int)(i - PkgCmdIDList.cmdidContestOption1Command)].id.ToString() + " " + recentContests[(int)(i - PkgCmdIDList.cmdidContestOption1Command)].name; } try { this.problems = Codeforces.getProblems(recentContests[0].id); for (uint i = PkgCmdIDList.cmdidTestACommand; i <= PkgCmdIDList.cmdidTestTCommand; i++) { CommandID cmdID = new CommandID(GuidList.guidCF_TesterCmdSet, (int)i); OleMenuCommand mc = (OleMenuCommand)mcs.FindCommand(cmdID); if ((int)(i - PkgCmdIDList.cmdidTestACommand) < problems.Count) { mc.Text = problems[(int)(i - PkgCmdIDList.cmdidTestACommand)].index; } mc.Visible = (int)(i - PkgCmdIDList.cmdidTestACommand) < problems.Count; } } catch (FailedRequestException exception) { MessageBox.Show(exception.Message, "Codeforces Tester", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void InitializeMenuCommand() { // Create the package IVsPackage package = new VSThrowawayPackagePackage() as IVsPackage; Assert.IsNotNull(package, "The object does not implement IVsPackage"); // Create a basic service provider OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices(); // Add site support to register editor factory BaseMock registerEditor = VSThrowawayPackage_UnitTests.EditorTests.RegisterEditorsServiceMock.GetRegisterEditorsInstance(); serviceProvider.AddService(typeof(SVsRegisterEditors), registerEditor, false); // Site the package Assert.AreEqual(0, package.SetSite(serviceProvider), "SetSite did not return S_OK"); //Verify that the menu command can be found CommandID menuCommandID = new CommandID(VSJamSession.VSThrowawayPackage.GuidList.guidVSThrowawayPackageCmdSet, (int)VSJamSession.VSThrowawayPackage.PkgCmdIDList.startJamSession); System.Reflection.MethodInfo info = typeof(Package).GetMethod("GetService", BindingFlags.Instance | BindingFlags.NonPublic); Assert.IsNotNull(info); OleMenuCommandService mcs = info.Invoke(package, new object[] { (typeof(IMenuCommandService)) }) as OleMenuCommandService; Assert.IsNotNull(mcs.FindCommand(menuCommandID)); }
// -------------------------------------------------------------------------------------------- /// <summary> /// Registers command handlers with the appropriate OleMenuCommandService. /// </summary> /// <param name="local">Local OleMenuCommandService instance.</param> /// <param name="parent">Global OleMenuCommandService instance.</param> /// <remarks> /// Promoted command handlers are merged with the parent OleMenuService instance. /// </remarks> // -------------------------------------------------------------------------------------------- public void RegisterCommandHandlers(OleMenuCommandService local, OleMenuCommandService parent) { var targetInfo = GetTargetInfo(); foreach (var menuGroup in targetInfo.Values) { foreach (var menuInfo in menuGroup.Values) { // --- Register the command with the local OleMenuCommandService var id = new CommandID(menuInfo.Guid, (int)menuInfo.Id); var command = new OleMenuCommand( ExecEventHandler, ChangeEventHandler, QueryStatusEventHandler, id); menuInfo.OleMenuCommand = command; local.AddCommand(command); // --- Promote to the parent OleMenuCommandService, if required. if (menuInfo.Promote && parent != null) { if (parent.FindCommand(id) == null) { parent.AddCommand(command); } } } } }
public static void UpdateShowInternalErrorsButton(bool value) { var toolbarButtonCommandId = GenerateCommandID(ShowInternalErrorsCommandID); var menuItem = _commandService.FindCommand(toolbarButtonCommandId); menuItem.Checked = value; }
public void InitializeMenuCommand() { // Create the package IVsPackage package = new ParametersXmlAddinPackage() as IVsPackage; Assert.IsNotNull(package, "The object does not implement IVsPackage"); // Create a basic service provider OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices(); BaseMock activityLogMock = new GenericMockFactory("MockVsActivityLog", new[] { typeof(Microsoft.VisualStudio.Shell.Interop.IVsActivityLog) }).GetInstance(); serviceProvider.AddService( typeof(Microsoft.VisualStudio.Shell.Interop.SVsActivityLog), activityLogMock, true); // Site the package Assert.AreEqual(0, package.SetSite(serviceProvider), "SetSite did not return S_OK"); //Verify that the menu command can be found CommandID menuCommandID = new CommandID(BlackMarble.ParametersXmlAddin.GuidList.guidParametersXmlAddinCmdSet, (int)BlackMarble.ParametersXmlAddin.PkgCmdIDList.cmdidGenerateParametersXmlFile); System.Reflection.MethodInfo info = typeof(Package).GetMethod("GetService", BindingFlags.Instance | BindingFlags.NonPublic); Assert.IsNotNull(info); OleMenuCommandService mcs = info.Invoke(package, new object[] { (typeof(IMenuCommandService)) }) as OleMenuCommandService; Assert.IsNotNull(mcs.FindCommand(menuCommandID)); }
/// <summary> /// This function is the callback used to handle the cmdidSetParamDescription command. /// </summary> private void OnSetParamDescription(object sender, EventArgs e) { OleMenuCmdEventArgs eventArgs = (OleMenuCmdEventArgs)e; string strCommandArg = eventArgs.InValue.ToString(); if (strCommandArg.Length > 0) { // Retrieve the command and set it's ParametersDescription property OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { CommandID testCommandId = new CommandID(GuidList.guidAllowParamsCmdSet, (int)PkgCmdIDList.cmdidTestCommand); OleMenuCommand testCommand = mcs.FindCommand(testCommandId) as OleMenuCommand; if (testCommand != null) { // Set the ParametersDescription testCommand.ParametersDescription = strCommandArg; // Update the AllowParams Options Dialog as well EnvDTE.DTE dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE)); dte.get_Properties("AllowParams Package", "Settings").Item("ParametersDescription").Value = strCommandArg; } } } else // invoke options dialog when command invoked with no parameters { EnvDTE.DTE dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE)); dte.ExecuteCommand("Tools.Options", typeof(OptionsPage).GUID.ToString()); } }
public void InitializeConfigMenuCommands() { // Create the package IVsPackage package = new TestPackage(); Assert.IsNotNull(package, "The object does not implement IVsPackage"); // Create a basic service provider OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices(); BaseMock uiShellService = MyToolWindowTest.UIShellServiceMock.GetUiShellInstanceCreateToolWin(); serviceProvider.AddService(typeof(SVsUIShell), uiShellService, false); BaseMock vsShellService = VSShellMock.GetVsShellInstance0(); serviceProvider.AddService(typeof(SVsShell), vsShellService, false); // Site the package Assert.AreEqual(0, package.SetSite(serviceProvider), "SetSite did not return S_OK"); //Verify that the menu command can be found CommandID menuCommandID = new CommandID(GuidList.GUIDTestPackageCmdSet, (int)PkgCmdIDList.cmdTestSettings); MethodInfo info = typeof(Package).GetMethod("GetService", BindingFlags.Instance | BindingFlags.NonPublic); Assert.IsNotNull(info); OleMenuCommandService mcs = info.Invoke(package, new object[] { (typeof(IMenuCommandService)) }) as OleMenuCommandService; Assert.IsNotNull(mcs); Assert.IsNotNull(mcs.FindCommand(menuCommandID)); }
public void TestIgnore() { CodeSweep.VSPackage.TaskProvider_Accessor accessor = new CodeSweep.VSPackage.TaskProvider_Accessor(_serviceProvider); Project project = Utilities.SetupMSBuildProject(); Utilities.RegisterProjectWithMocks(project, _serviceProvider); MockTermTable table = new MockTermTable("termtable.xml"); MockTerm term0 = new MockTerm("dupText", 0, "term0Class", "term0Comment", "term0recommended", table); MockTerm term1 = new MockTerm("term2Text", 2, "term2Class", "term2Comment", "term2recommended", table); MockScanHit hit0 = new MockScanHit("file0", 1, 5, "line text", term0, null); MockScanHit hit1 = new MockScanHit("file1", 4, 1, "line text 2", term1, null); MockScanHit hit2 = new MockScanHit("file2", 3, 2, "line text 3", term1, null); MockScanResult scanResult = new MockScanResult("file0", new IScanHit[] { hit0, hit1, hit2 }, true); accessor.AddResult(scanResult, project.FullPath); IVsEnumTaskItems enumerator = null; accessor.EnumTaskItems(out enumerator); List <IVsTaskItem> items = Utilities.TasksFromEnumerator(enumerator); CodeSweep.VSPackage.Task_Accessor task0Accessor = new CodeSweep.VSPackage.Task_Accessor(new PrivateObject(items[0])); CodeSweep.VSPackage.Task_Accessor task1Accessor = new CodeSweep.VSPackage.Task_Accessor(new PrivateObject(items[1])); MockTaskList taskList = _serviceProvider.GetService(typeof(SVsTaskList)) as MockTaskList; // Ensure cmd is disabled with no selection OleMenuCommandService mcs = _serviceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService; MenuCommand command = mcs.FindCommand(new CommandID(CodeSweep.VSPackage.GuidList_Accessor.guidVSPackageCmdSet, (int)CodeSweep.VSPackage.PkgCmdIDList_Accessor.cmdidIgnore)); // NOTE: simply getting command.Supported or command.Enabled doesn't seem to invoke // QueryStatus, so I'll explicitly call the status update method as a workaround. accessor.QueryIgnore(null, EventArgs.Empty); Assert.IsTrue(command.Supported, "Command not supported."); Assert.IsFalse(command.Enabled, "Command enabled with no selection."); // Ensure cmd is disabled with an ignored item selected task0Accessor.Ignored = true; taskList.SetSelected(items[0], true); accessor.QueryIgnore(null, EventArgs.Empty); Assert.IsFalse(command.Enabled, "Command enabled with ignored item selected."); // Ensure cmd is enabled with one ignored and one non-ignored item selected taskList.SetSelected(items[1], true); accessor.QueryIgnore(null, EventArgs.Empty); Assert.IsTrue(command.Enabled, "Command disabled with a non-ignored item selected."); // Fire cmd, ensure selected items are ignored command.Invoke(); accessor.QueryIgnore(null, EventArgs.Empty); Assert.IsTrue(task0Accessor.Ignored, "Command set ignored task to non-ignored."); Assert.IsTrue(task1Accessor.Ignored, "Command did not set non-ignored task to ignored."); // Ensure cmd is now disabled accessor.QueryIgnore(null, EventArgs.Empty); Assert.IsFalse(command.Enabled, "Command still enabled after invocation."); }
public void onUIContext(int ctx, int active) { if (active != 0) { m_context |= ctx; } else { m_context &= ~ctx; if (ctx == (int)UIContext.Debugging) { m_context &= (int)~UIContext.AlcStart; } } OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { foreach (CommandData c in m_commands) { MenuCommand item = mcs.FindCommand(c.ID); if (item != null) { item.Enabled = c.Condition(m_context); } } } }
/// <summary> /// Invokes the Stadia Debugger Options command. /// </summary> /// <param name="command">The Stadia Debugger Options command. Example: "list".</param> void Invoke(object command) { MenuCommand menuCommand = menuCommandService.FindCommand( new CommandID(YetiConstants.CommandSetGuid, PkgCmdID.cmdidDebuggerOptionsCommand)); Assert.That(menuCommand, Is.Not.Null); menuCommand.Invoke(command); }
/// <summary> /// Invokes the LLDB Shell command. /// </summary> /// <param name="command">The LLDB shell command. Example: "help".</param> private void Invoke(object command) { var menuCommand = menuCommandService.FindCommand( new CommandID(YetiConstants.CommandSetGuid, PkgCmdID.cmdidLLDBShellExec)); Assert.That(menuCommand, Is.Not.Null); menuCommand.Invoke(command); }
public void InitializeMenuCommand() { using (ServiceProviderHelper.SetSite(package)) { //Verify that the menu command can be found OleMenuCommandService mcs = ReflectionHelper.InvokeMethod <Package, OleMenuCommandService>(package, "GetService", typeof(IMenuCommandService)); Assert.IsNotNull(mcs.FindCommand(new CommandID(AnkhId.CommandSetGuid, (int)Ankh.AnkhCommand.Refresh))); } }
/// <summary> /// Updates "Run" buttons state according to number of error rows in the grid /// </summary> private void Panel_HasErrorChanged(object sender, EventArgs e) { try { menuService.FindCommand(runCommandID).Supported = !panel.ToolGrid.HasError; } catch (Exception ex) { VLOutputWindow.VisualLocalizerPane.WriteException(ex); VisualLocalizer.Library.Components.MessageBox.ShowException(ex); } }
private void EnableCommand(bool enable, OleMenuCommandService service, int commandGuid) { if (service != null) { CommandID toolbarMenuCommandID = new CommandID(Guids.guidConfluenceToolbarMenu, commandGuid); MenuCommand onToolbarMenuCommandClick = service.FindCommand(toolbarMenuCommandID); onToolbarMenuCommandClick.Enabled = enable; } }
private void ShowIgnoredInstances(object sender, EventArgs e) { _showingIgnoredInstances = !_showingIgnoredInstances; OleMenuCommandService mcs = _serviceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService; mcs.FindCommand(new CommandID(GuidList.guidVSPackageCmdSet, (int)PkgCmdIDList.cmdidShowIgnoredInstances)).Checked = _showingIgnoredInstances; Refresh(); }
/// <summary> /// create the list of tasks and replace the placeholder menu /// </summary> /// <param name="dir"></param> private void setupRakeTasksMenu(string dir) { try { List <RakeTask> tasks; //update if cache not exist if (!taskCache.ContainsKey(dir)) { updateCache(dir); } //get the tasks from the cache for the directory taskCache.TryGetValue(dir, out tasks); OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; // Add our command handlers for menu (commands must exist in the .vsct file) if (null != mcs) { //if there is any task in menu, remove them all. foreach (var command in currentCommandsInMenu) { var cmdID = new CommandID( GuidList.guidRakeRunnerCmdSet, command); var menu = mcs.FindCommand(cmdID); if (menu != null) { mcs.RemoveCommand(menu); } } //clear the commands list currentCommandsInMenu.Clear(); if (tasks != null) { //add the tasks for (int i = 0; i < tasks.Count; i++) { int commandId = (int)PkgCmdIDList.icmdTasksList + i; var cmdID = new CommandID( GuidList.guidRakeRunnerCmdSet, commandId); var mc = new OleMenuCommand(RakeTaskSelected, cmdID); mc.Text = tasks[i].Task; mcs.AddCommand(mc); //store the commandid so we can remove when re-creating the menu currentCommandsInMenu.Add(commandId); } } //var tasks = rakeService.GetRakeTasks() } } catch { } }
public Task InitializeAsync() { OleMenuCommandService commandService = _serviceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (commandService == null) { _logger.WriteLine("OleMenuCommandService was not resolved"); return(Task.CompletedTask); } var id = 1; foreach (var iconType in ExtensionCatalogue.IconTypes) { var names = Enum.GetNames(iconType); var values = Enum.GetValues(iconType); for (var idx = 0; idx < names.Length; idx++) { var cmdidMyDynamicStartCommand = id * 100; var value = (int)values.GetValue(idx); var icon = new ExtensionMethodIcon(iconType, value); CommandID dynamicItemRootId = new CommandID(guidDynamicCommandsSet.SetId, cmdidMyDynamicStartCommand); var existing = commandService.FindCommand(dynamicItemRootId); if (existing != null) { commandService.RemoveCommand(existing); } var matchingMethods = _extensionsCacheService.ExtensionsForIcon(icon); if (matchingMethods.Any()) { DynamicItemMenuCommand dynamicMenuCommand = new DynamicItemMenuCommand( _extensionsCacheService, _invocationService, dynamicItemRootId, cmdidMyDynamicStartCommand, matchingMethods ) { Visible = false }; commandService.AddCommand(dynamicMenuCommand); } id++; } } return(Task.CompletedTask); }
private void InitializeCommands(OleMenuCommandService service) { if (service != null) { CommandID toolbarMenuCommandRefreshID = new CommandID(Guids.guidConfluenceToolbarMenu, Guids.COMMAND_REFRESH_ID); MenuCommand onToolbarMenuCommandRefreshClick = new MenuCommand(RefreshSpacesAsync, toolbarMenuCommandRefreshID); service.RemoveCommand(service.FindCommand(toolbarMenuCommandRefreshID)); service.AddCommand(onToolbarMenuCommandRefreshClick); } }
public int OnAfterOpenSolution(object pUnkReserved, int fNewSolution) { OleMenuCommandService mcs = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { var menu = mcs.FindCommand(new CommandID(CommandSet, CommandId)); menu.Visible = true; } return(VSConstants.S_OK); }
public static void RemoveCommandHandler(IServiceProvider serviceProvider, uint id) { OleMenuCommandService mcs = serviceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (mcs != null) { MenuCommand command = mcs.FindCommand(new CommandID(CodeSweep.VSPackage.GuidList_Accessor.guidVSPackageCmdSet, (int)id)); if (command != null) { mcs.RemoveCommand(command); } } }
async Task SaveSettingsToStorageAuxAsync() { // Retrieve the command and change its visibility OleMenuCommandService commandService = this.GetService(typeof(System.ComponentModel.Design.IMenuCommandService)) as OleMenuCommandService; var yellowCommand = commandService.FindCommand(new System.ComponentModel.Design.CommandID(YellowCommand.CommandSet, YellowCommand.CommandId)); yellowCommand.Visible = IsDisplayingYellowCommand; // Write custom property to the registry await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider); var userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); userSettingsStore.SetBoolean(registryCollectionPath, propertyName, IsDisplayingYellowCommand); }
private void RegisterCommand( OleMenuCommandService commandService, Guid menuCommandGroupGuid, int commandIdNumber, EventHandler handler) { var commandId = new CommandID(menuCommandGroupGuid, commandIdNumber); var menuCommand = new MenuCommand(handler, commandId); if (commandService.FindCommand(commandId) != null) { commandService.RemoveCommand(menuCommand); //Is this step needed? } commandService.AddCommand(menuCommand); Debug.WriteLine($"Registered command {nameof(commandService)}: {menuCommandGroupGuid} - {commandIdNumber}"); }
private void QueryDontIgnore(object sender, EventArgs e) { OleMenuCommandService mcs = _serviceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService; MenuCommand command = mcs.FindCommand(new CommandID(GuidList.guidVSPackageCmdSet, (int)PkgCmdIDList.cmdidDoNotIgnore)); if (IsActiveProvider) { bool anyIgnored = !SelectedTasks().TrueForAll( delegate(Task task) { return(!task.Ignored); }); command.Supported = true; command.Enabled = anyIgnored; } else { command.Supported = false; } }
private void RefreshAppPoolMenu(OleMenuCommandService mcs) { var appPools = LookupAppPools.GetAppPoolProcesses(); int j = 0; foreach (var appPool in appPoolList) { var cmdID = new CommandID(GuidList.guidNielsV_AttachToAppPoolCmdSet, this.baseMRUID + j); var menuCommand = mcs.FindCommand(cmdID) as OleMenuCommand; if (j >= 0 && j < this.appPoolList.Count && j < appPools.Count) { menuCommand.Text = appPools.Values.ElementAt(j); menuCommand.Visible = true; } else { menuCommand.Visible = false; } j++; } }
public void Constructor_CommandAvailabilityChecked() { // Arrange var spMock = Mock.Of <IServiceProvider>(); var cs = new OleMenuCommandService(spMock); var casMock = new Mock <ICommandAvailabilityService>(); var handleCommandAvailabilityCalled = false; casMock.Setup(m => m.HandleCommandAvailability(It.IsNotNull <Action <bool> >(), It.IsNotNull <Action <bool> >())) .Callback((Action <bool> setVisibleAction, Action <bool> setEnabledAction) => { handleCommandAvailabilityCalled = true; setVisibleAction(false); setEnabledAction(false); }); const int commandIdInt = 4711; var commandSet = Guid.Parse("{110031CC-14A1-44FA-83D1-D970918981AC}"); var commandId = new CommandID(commandSet, commandIdInt); // Act var cmd = new BaseCommandTestImplementation(cs, casMock.Object, commandIdInt, commandSet); Assert.IsNotNull(cmd); var registeredCommand = cs.FindCommand(commandId); Assert.IsNotNull(registeredCommand); Assert.IsTrue(registeredCommand.Visible); Assert.IsTrue(registeredCommand.Enabled); var status = registeredCommand.OleStatus; // Assert Assert.AreNotEqual(0, status); Assert.IsTrue(handleCommandAvailabilityCalled); Assert.IsFalse(registeredCommand.Visible); Assert.IsFalse(registeredCommand.Enabled); }
public void InitializeMenuCommand() { // Create the package IVsPackage package = new VsOnBuildExtensionPackage() as IVsPackage; Assert.IsNotNull(package, "The object does not implement IVsPackage"); // Create a basic service provider OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices(); // Site the package Assert.AreEqual(0, package.SetSite(serviceProvider), "SetSite did not return S_OK"); //Verify that the menu command can be found CommandID menuCommandID = new CommandID(CleverMonkeys.VSOnBuildExtension.GuidList.guidVSOnBuildExtensionCmdSet, (int)CleverMonkeys.VSOnBuildExtension.PkgCmdIDList.cmdidIISReset); System.Reflection.MethodInfo info = typeof(Package).GetMethod("GetService", BindingFlags.Instance | BindingFlags.NonPublic); Assert.IsNotNull(info); OleMenuCommandService mcs = info.Invoke(package, new object[] { (typeof(IMenuCommandService)) }) as OleMenuCommandService; Assert.IsNotNull(mcs.FindCommand(menuCommandID)); }
public void Constructor_CommandAddedSuccessfully() { // Arrange var spMock = Mock.Of <IServiceProvider>(); var cs = new OleMenuCommandService(spMock); var casMock = Mock.Of <ICommandAvailabilityService>(); const int commandIdInt = 4711; var commandSet = Guid.Parse("{110031CC-14A1-44FA-83D1-D970918981AC}"); var commandId = new CommandID(commandSet, commandIdInt); // Act var cmd = new BaseCommandTestImplementation(cs, casMock, commandIdInt, commandSet); // Assert Assert.IsNotNull(cmd); var registeredCommand = cs.FindCommand(commandId); Assert.IsNotNull(registeredCommand); }
public void InitializeMenuCommand() { // Create the package IVsPackage package = new VSCopyLocalPackage(); Assert.IsNotNull(package, "The object does not implement IVsPackage"); // Create a basic service provider OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices(); // Site the package Assert.AreEqual(0, package.SetSite(serviceProvider), "SetSite did not return S_OK"); //Verify that the menu command can be found var menuCommandID = new CommandID(GuidList.GuidVSCopyLocalCmdSet, (int)PkgCmdIDList.CmdidProjectCommand); MethodInfo info = typeof(Package).GetMethod("GetService", BindingFlags.Instance | BindingFlags.NonPublic); Assert.IsNotNull(info); OleMenuCommandService mcs = info.Invoke(package, new object[] { (typeof(IMenuCommandService)) }) as OleMenuCommandService; Assert.IsNotNull(mcs.FindCommand(menuCommandID)); }
public void InitializeMenuCommand() { // Create the package IVsPackage package = new DapperFactoryPackage() as IVsPackage; Assert.IsNotNull(package, "The object does not implement IVsPackage"); // Create a basic service provider OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices(); // Site the package Assert.AreEqual(0, package.SetSite(serviceProvider), "SetSite did not return S_OK"); //Verify that the menu command can be found CommandID menuCommandID = new CommandID(Chambersoft.DapperFactory.GuidList.guidDapperFactoryCmdSet, (int)Chambersoft.DapperFactory.PkgCmdIDList.dfGenerateServiceInterfaces); System.Reflection.MethodInfo info = typeof(Package).GetMethod("GetService", BindingFlags.Instance | BindingFlags.NonPublic); Assert.IsNotNull(info); OleMenuCommandService mcs = info.Invoke(package, new object[] { (typeof(IMenuCommandService)) }) as OleMenuCommandService; Assert.IsNotNull(mcs.FindCommand(menuCommandID)); }