Example #1
0
        private void OnProjectContextMenuInvokeHandler(object sender, EventArgs e)
        {
            var menuCommand = sender as MenuCommand;

            if (menuCommand == null || _dte2.SelectedItems.Count != 1)
            {
                return;
            }

            var project = _dte2.SelectedItems.Item(1).Project;

            if (project == null)
            {
                return;
            }
            string path = null;

            if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidDgmlBuild ||
                menuCommand.CommandID.ID == PkgCmdIDList.cmdidDebugViewBuild ||
                menuCommand.CommandID.ID == PkgCmdIDList.cmdidSqlBuild)
            {
                path = LocateProjectAssemblyPath(project);
                if (path == null)
                {
                    return;
                }
            }

            if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidReverseEngineerCodeFirst)
            {
                _reverseEngineerHandler.ReverseEngineerCodeFirst(project);
            }
            else if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidReverseEngineerDgml)
            {
                _serverDgmlHandler.GenerateServerDgmlFiles();
            }
            else if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidDgmlNuget)
            {
                _dgmlNugetHandler.InstallDgmlNuget(project);
            }
            else if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidDgmlBuild)
            {
                _modelAnalyzerHandler.Generate(path, project, GenerationType.Dgml);
            }
            else if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidSqlBuild)
            {
                _modelAnalyzerHandler.Generate(path, project, GenerationType.Ddl);
            }
            else if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidDebugViewBuild)
            {
                _modelAnalyzerHandler.Generate(path, project, GenerationType.DebugView);
            }
            else if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidAbout)
            {
                _aboutHandler.ShowDialog();
            }
        }
        private async System.Threading.Tasks.Task OnProjectContextMenuInvokeHandlerAsync(object sender, EventArgs e)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            var menuCommand = sender as MenuCommand;

            if (menuCommand == null || _dte2.SelectedItems.Count != 1)
            {
                return;
            }

            var project = _dte2.SelectedItems.Item(1).Project;

            if (project == null)
            {
                return;
            }
            string path = null;

            if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidDgmlBuild ||
                menuCommand.CommandID.ID == PkgCmdIDList.cmdidDebugViewBuild ||
                menuCommand.CommandID.ID == PkgCmdIDList.cmdidSqlBuild ||
                menuCommand.CommandID.ID == PkgCmdIDList.cmdidMigrationStatus)
            {
                path = await LocateProjectAssemblyPathAsync(project);

                if (path == null)
                {
                    return;
                }
            }

            if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidReverseEngineerCodeFirst)
            {
                await _reverseEngineerHandler.ReverseEngineerCodeFirstAsync(project);
            }
            else if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidReverseEngineerDgml)
            {
                _serverDgmlHandler.GenerateServerDgmlFiles();
            }
            else if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidDgmlNuget)
            {
                await _dgmlNugetHandler.InstallDgmlNugetAsync(project);
            }
            else if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidDgmlBuild)
            {
                await _modelAnalyzerHandler.GenerateAsync(path, project, GenerationType.Dgml);
            }
            else if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidSqlBuild)
            {
                await _modelAnalyzerHandler.GenerateAsync(path, project, GenerationType.Ddl);
            }
            else if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidDebugViewBuild)
            {
                await _modelAnalyzerHandler.GenerateAsync(path, project, GenerationType.DebugView);
            }
            else if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidMigrationStatus)
            {
                await _migrationsHandler.ManageMigrationsAsync(path, project);
            }
            else if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidAbout)
            {
                _aboutHandler.ShowDialog();
            }
        }