Example #1
0
#pragma warning disable VSTHRD100 // Avoid async void methods
        private async void OnReverseEngineerConfigFileMenuInvokeHandler(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 item = await VS.Solutions.GetActiveItemAsync();

                if (item == null)
                {
                    return;
                }

                if (!IsConfigFile(item.Text))
                {
                    return;
                }

                Project project = FindProject(item);
                if (project == null)
                {
                    return;
                }

                string filename = item.FullPath;

                if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidReverseEngineerEdit)
                {
                    await reverseEngineerHandler.ReverseEngineerCodeFirstAsync(project, filename, false);
                }
                else if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidReverseEngineerRefresh)
                {
                    await reverseEngineerHandler.ReverseEngineerCodeFirstAsync(project, filename, true);
                }
            }
            catch (Exception ex)
            {
                LogError(new List <string>(), ex);
            }
        }
Example #2
0
        private async System.Threading.Tasks.Task OnReverseEngineerConfigFileMenuInvokeHandlerAsync(object sender, EventArgs e)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            var menuCommand = sender as MenuCommand;

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

            var itemName = _dte2.SelectedItems.Item(1).Name;

            if (itemName == null ||
                !itemName.StartsWith("efpt.", StringComparison.OrdinalIgnoreCase) ||
                !itemName.EndsWith("config.json", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            string filename = (string)_dte2.SelectedItems.Item(1).ProjectItem.Properties.Item("FullPath").Value;

            var project = _dte2.SelectedItems.Item(1).ProjectItem.ContainingProject;

            if (project == null)
            {
                return;
            }

            if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidReverseEngineerEdit)
            {
                await _reverseEngineerHandler.ReverseEngineerCodeFirstAsync(project, filename, false);
            }
            else if (menuCommand.CommandID.ID == PkgCmdIDList.cmdidReverseEngineerRefresh)
            {
                await _reverseEngineerHandler.ReverseEngineerCodeFirstAsync(project, filename, true);
            }
        }
Example #3
0
        private async System.Threading.Tasks.Task OnProjectContextMenuInvokeHandlerAsync(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)
            {
                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();
            }
        }