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 ||
                menuCommand.CommandID.ID == PkgCmdIDList.cmdidDbCompare)
            {
                path = await LocateProjectAssemblyPathAsync(project);

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

            if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidReverseEngineerCodeFirst)
            {
                await _reverseEngineerHandler.ReverseEngineerCodeFirstAsync(project);
            }
            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();
            }
            else if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidDbCompare)
            {
                await _compareHandler.HandleComparisonAsync(path, project);
            }
        }
Пример #2
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 ||
                menuCommand.CommandID.ID == PkgCmdIDList.cmdidMigrationStatus)
            {
                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.cmdidMigrationStatus)
            {
                _migrationsHandler.ManageMigrations(path, project);
            }
            else if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidAbout)
            {
                _aboutHandler.ShowDialog();
            }
        }
Пример #3
0
#pragma warning disable VSTHRD100 // Avoid async void methods
        private async void OnProjectContextMenuInvokeHandler(object sender, EventArgs e)
#pragma warning restore VSTHRD100 // Avoid async void methods
        {
            try
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                var menuCommand = sender as MenuCommand;
                if (menuCommand == null || (await VS.Solutions.GetActiveItemsAsync()).Count() != 1)
                {
                    return;
                }

                var project = await VS.Solutions.GetActiveProjectAsync();

                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 ||
                    menuCommand.CommandID.ID == PkgCmdIDList.cmdidDbCompare)
                {
                    path = await LocateProjectAssemblyPathAsync(project);

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

                if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidReverseEngineerCodeFirst)
                {
                    await reverseEngineerHandler.ReverseEngineerCodeFirstAsync(project);
                }
                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();
                }
                else if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidDbCompare)
                {
                    await compareHandler.HandleComparisonAsync(path, project);
                }
            }
            catch (Exception ex)
            {
                LogError(new List <string>(), ex);
            }
        }