예제 #1
0
        async Task InitializeMenus()
        {
            if (!ExportForVisualStudioProcessAttribute.IsVisualStudioProcess())
            {
                log.Warning("Don't initialize menus for non-Visual Studio process");
                return;
            }

            var componentModel = (IComponentModel)(await GetServiceAsync(typeof(SComponentModel)));

            Assumes.Present(componentModel);

            var exports  = componentModel.DefaultExportProvider;
            var commands = new IVsCommandBase[]
            {
                exports.GetExportedValue <INextInlineCommentCommand>(),
                exports.GetExportedValue <IPreviousInlineCommentCommand>(),
                exports.GetExportedValue <IToggleInlineCommentMarginCommand>()
            };

            await JoinableTaskFactory.SwitchToMainThreadAsync();

            var menuService = (IMenuCommandService)(await GetServiceAsync(typeof(IMenuCommandService)));

            Assumes.Present(menuService);

            menuService.AddCommands(commands);
        }
예제 #2
0
        protected void InitializeMenus()
        {
            IVsCommandBase[] commands;
            if (ProcessHelper.IsRunningInsideVisualStudio())
            {
                var componentModel = (IComponentModel)GetService(typeof(SComponentModel));
                var exports        = componentModel.DefaultExportProvider;

                commands = new IVsCommandBase[]
                {
                    exports.GetExportedValue <IAboutCommand>(),
                    exports.GetExportedValue <IShowSharperCryptoAnalysisPaneCommand>(),
                    exports.GetExportedValue <IAddCryptoTaskCommand>(),
                };
            }
            else
            {
                commands = new IVsCommandBase[0];
                VsShellUtilities.ShowMessageBox(this, "This extension only is available in Visual Studio", null,
                                                OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
            }

            var menuService = (IMenuCommandService)GetService(typeof(IMenuCommandService));

            menuService?.AddCommands(commands);
        }
예제 #3
0
        async Task InitializeMenus()
        {
            var componentModel = (IComponentModel)(await GetServiceAsync(typeof(SComponentModel)));
            var exports        = componentModel.DefaultExportProvider;
            var commands       = new IVsCommandBase[]
            {
                exports.GetExportedValue <INextInlineCommentCommand>(),
                exports.GetExportedValue <IPreviousInlineCommentCommand>()
            };

            await JoinableTaskFactory.SwitchToMainThreadAsync();

            var menuService = (IMenuCommandService)(await GetServiceAsync(typeof(IMenuCommandService)));

            menuService.AddCommands(commands);
        }
예제 #4
0
        async Task InitializeMenus()
        {
            IVsCommandBase[] commands;
            if (ExportForVisualStudioProcessAttribute.IsVisualStudioProcess())
            {
                var componentModel = (IComponentModel)(await GetServiceAsync(typeof(SComponentModel)));
                Assumes.Present(componentModel);

                var exports = componentModel.DefaultExportProvider;
                commands = new IVsCommandBase[]
                {
                    exports.GetExportedValue <IAddConnectionCommand>(),
                    exports.GetExportedValue <IBlameLinkCommand>(),
                    exports.GetExportedValue <ICopyLinkCommand>(),
                    exports.GetExportedValue <ICreateGistCommand>(),
                    exports.GetExportedValue <ICreateGistEnterpriseCommand>(),
                    exports.GetExportedValue <IOpenLinkCommand>(),
                    exports.GetExportedValue <IOpenPullRequestsCommand>(),
                    exports.GetExportedValue <IShowCurrentPullRequestCommand>(),
                    exports.GetExportedValue <IShowGitHubPaneCommand>(),
                    exports.GetExportedValue <IGoToSolutionOrPullRequestFileCommand>(),
                    exports.GetExportedValue <ISyncSubmodulesCommand>(),
                    exports.GetExportedValue <IOpenFromUrlCommand>(),
                    exports.GetExportedValue <IOpenFromClipboardCommand>()
                };
            }
            else
            {
                // Show info message box when executed in non-Visual Studio process
                var message = Resources.BlendDialogText;
                commands = new IVsCommandBase[]
                {
                    new ShowMessageBoxCommand(AddConnectionCommand.CommandSet, AddConnectionCommand.CommandId, this, message),
                    new ShowMessageBoxCommand(ShowGitHubPaneCommand.CommandSet, ShowGitHubPaneCommand.CommandId, this, message)
                };
            }

            await JoinableTaskFactory.SwitchToMainThreadAsync();

            var menuService = (IMenuCommandService)(await GetServiceAsync(typeof(IMenuCommandService)));

            Assumes.Present(menuService);

            menuService.AddCommands(commands);
        }
예제 #5
0
        async Task InitializeMenus()
        {
            var componentModel = (IComponentModel)(await GetServiceAsync(typeof(SComponentModel)));
            var exports        = componentModel.DefaultExportProvider;
            var commands       = new IVsCommandBase[]
            {
                exports.GetExportedValue <IAddConnectionCommand>(),
                exports.GetExportedValue <IBlameLinkCommand>(),
                exports.GetExportedValue <ICopyLinkCommand>(),
                exports.GetExportedValue <ICreateGistCommand>(),
                exports.GetExportedValue <IOpenLinkCommand>(),
                exports.GetExportedValue <IOpenPullRequestsCommand>(),
                exports.GetExportedValue <IShowCurrentPullRequestCommand>(),
                exports.GetExportedValue <IShowGitHubPaneCommand>()
            };

            await JoinableTaskFactory.SwitchToMainThreadAsync();

            var menuService = (IMenuCommandService)(await GetServiceAsync(typeof(IMenuCommandService)));

            menuService.AddCommands(commands);
        }