PromptUser() public static method

Starts the publish wizard for the given project.
public static PromptUser ( ISolutionProject project ) : void
project ISolutionProject The project to publish.
return void
Ejemplo n.º 1
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void OnDeployCommand(object sender, EventArgs e)
        {
            var selectedProject = SolutionHelper.CurrentSolution.SelectedProject;

            Debug.WriteLine($"Deploying project: {selectedProject.FullPath}");
            PublishDialogWindow.PromptUser(selectedProject);
        }
        /// <summary>
        /// Initializes the singleton instance of the command.
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        /// <param name="token"></param>
        public static async Task InitializeAsync(IGoogleCloudExtensionPackage package, CancellationToken token)
        {
            if (package == null)
            {
                throw new ArgumentNullException(nameof(package));
            }

            if (await package.GetServiceAsync(typeof(IMenuCommandService)) is OleMenuCommandService commandService)
            {
                await package.JoinableTaskFactory.SwitchToMainThreadAsync(token);

                var menuCommandID = new CommandID(CommandSet, CommandId);
                var menuItem      = new OleMenuCommand(OnDeployCommand, menuCommandID);
                menuItem.BeforeQueryStatus += OnBeforeQueryStatus;
                commandService.AddCommand(menuItem);
            }

            // <summary>
            // This function is the callback used to execute the command when the menu item is clicked.
            // See the constructor to see how the menu item is associated with this function using
            // OleMenuCommandService service and MenuCommand class.
            // </summary>
            // <param name="sender">Event sender.</param>
            // <param name="e">Event args.</param>
            async void OnDeployCommand(object sender, EventArgs e)
            {
                await GoogleCloudExtensionPackage.Instance.JoinableTaskFactory.SwitchToMainThreadAsync();

                IParsedDteProject project = SolutionHelper.CurrentSolution.StartupProject.ParsedProject;

                PublishDialogWindow.PromptUser(project);
            }

            void OnBeforeQueryStatus(object sender, EventArgs e)
            {
#pragma warning disable VSTHRD109 // Switch instead of assert in async methods
                ThreadHelper.ThrowIfNotOnUIThread();
#pragma warning restore VSTHRD109 // Switch instead of assert in async methods
                if (!(sender is OleMenuCommand menuCommand))
                {
                    return;
                }

                menuCommand.Visible = true;

                IParsedDteProject startupProject = SolutionHelper.CurrentSolution.StartupProject?.ParsedProject;
                if (startupProject == null)
                {
                    menuCommand.Enabled = false;
                    menuCommand.Text    = Resources.PublishDialogGenericMenuHeader;
                }
                else
                {
                    menuCommand.Enabled =
                        PublishDialogWindow.CanPublish(startupProject) && !ShellUtils.Default.IsBusy();
                    menuCommand.Text = string.Format(Resources.PublishDialogProjectMenuHeader, startupProject.Name);
                }
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// This function is the callback used to execute the command when the menu item is clicked.
 /// See the constructor to see how the menu item is associated with this function using
 /// OleMenuCommandService service and MenuCommand class.
 /// </summary>
 /// <param name="sender">Event sender.</param>
 /// <param name="e">Event args.</param>
 private static void OnDeployCommand(object sender, EventArgs e)
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     ErrorHandlerUtils.HandleExceptions(() =>
     {
         IParsedDteProject selectedProject = SolutionHelper.CurrentSolution.SelectedProject.ParsedProject;
         Debug.WriteLine($"Deploying project: {selectedProject.FullPath}");
         PublishDialogWindow.PromptUser(selectedProject);
     });
 }