void IConnectionWorkflowExecutor.EstablishConnection(ConnectionInformation information) { ConnectionWorkflow workflow = new ConnectionWorkflow(this.host, this.ConnectCommand); IProgressEvents progressEvents = workflow.Run(information); SetConnectionInProgress(progressEvents); }
/// <summary> /// Checks if the <see cref="IProgressEvents"/> meets the requirements to be observable by this class /// </summary> /// <param name="progressEvents">An instance of <see cref="IProgressEvents"/> to check</param> private static void CheckSupportedProgressEvents(IProgressEvents progressEvents) { if (progressEvents.Steps == null) { throw new InvalidOperationException(ProgressObserverResources.UnsupportedProgressEventsException); } }
void IBindingWorkflowExecutor.BindProject(BindCommandArgs bindingArgs) { var workflow = CreateBindingWorkflow(bindingArgs); IProgressEvents progressEvents = workflow.Run(); Debug.Assert(progressEvents != null, "BindingWorkflow.Run returned null"); this.SetBindingInProgress(progressEvents, bindingArgs); }
public IProgressEvents Run(ConnectionInformation information) { Debug.Assert(this.host.ActiveSection != null, "Expect the section to be attached at least until this method returns"); this.OnProjectsChanged(information, null); IProgressEvents progress = ProgressStepRunner.StartAsync(this.host, this.host.ActiveSection.ProgressHost, (controller) => this.CreateConnectionSteps(controller, information)); this.DebugOnly_MonitorProgress(progress); return(progress); }
public IProgressEvents Run() { Debug.Assert(this.host.ActiveSection != null, "Expect the section to be attached at least until this method returns"); IProgressEvents progress = ProgressStepRunner.StartAsync(this.host, this.host.ActiveSection.ProgressHost, controller => this.CreateWorkflowSteps(controller)); this.DebugOnly_MonitorProgress(progress); return(progress); }
void IBindingWorkflowExecutor.BindProject(ProjectInformation projectInformation) { ConnectionInformation connection = this.host.VisualStateManager.GetConnectedServer(projectInformation); Debug.Assert(connection != null, "Could not find a connected server for project: " + projectInformation?.Key); BindingWorkflow workflowExecutor = new BindingWorkflow(this.host, connection, projectInformation); IProgressEvents progressEvents = workflowExecutor.Run(); Debug.Assert(progressEvents != null, "BindingWorkflow.Run returned null"); this.SetBindingInProgress(progressEvents, projectInformation); }
public IProgressEvents Run(ConnectionInformation information) { Debug.Assert(this.host.ActiveSection != null, "Expect the section to be attached at least until this method returns"); this.OnProjectsChanged(information, null); IProgressEvents progress = ProgressStepRunner.StartAsync(this.host, this.host.ActiveSection.ProgressHost, (controller) => this.CreateConnectionSteps(controller, information)); #if DEBUG progress.RunOnFinished(r => this.host.Logger.WriteLine("DEBUGONLY: Connect workflow finished, Execution result: {0}", r)); #endif return(progress); }
public IProgressEvents Run() { Debug.Assert(this.host.ActiveSection != null, "Expect the section to be attached at least until this method returns"); IProgressEvents progress = ProgressStepRunner.StartAsync(this.host, this.host.ActiveSection.ProgressHost, controller => this.CreateWorkflowSteps(controller)); #if DEBUG progress.RunOnFinished(r => this.host.Logger.WriteLine("DEBUGONLY: Binding workflow finished, Execution result: {0}", r)); #endif return(progress); }
public ProgressEventsVerifier(IProgressEvents events) { if (events == null) { throw new ArgumentNullException("events"); } this.events = events; events.Started += this.OnStarted; events.Finished += this.OnFinished; events.StepExecutionChanged += this.OnStepExecutionChanged; events.CancellationSupportChanged += this.OnCancellationSupportChanged; }
internal /*for testing purposes*/ void SetConnectionInProgress(IProgressEvents progressEvents) { this.IsConnectionInProgress = true; ProgressNotificationListener progressListener = new ProgressNotificationListener(progressEvents, this.host.Logger); progressListener.MessageFormat = Strings.ConnectingToSonarQubePrefixMessageFormat; progressEvents.RunOnFinished(result => { progressListener.Dispose(); this.IsConnectionInProgress = false; }); }
internal /*for testing purposes*/ void SetConnectionInProgress(IProgressEvents progressEvents) { this.IsConnectionInProgress = true; ProgressNotificationListener progressListener = new ProgressNotificationListener(this.ServiceProvider, progressEvents); progressListener.MessageFormat = Strings.ConnectingToSonarQubePrefixMessageFormat; progressEvents.RunOnFinished(result => { progressListener.Dispose(); this.IsConnectionInProgress = false; this.ShowNuGetWarning(result); }); }
internal /*for testing purposes*/ void SetBindingInProgress(IProgressEvents progressEvents, ProjectInformation projectInformation) { this.OnBindingStarted(); ProgressNotificationListener progressListener = new ProgressNotificationListener(this.ServiceProvider, progressEvents); progressListener.MessageFormat = Strings.BindingSolutionPrefixMessageFormat; progressEvents.RunOnFinished(result => { progressListener.Dispose(); this.OnBindingFinished(projectInformation, result == ProgressControllerResult.Succeeded); }); }
internal /*for testing purposes*/ void SetBindingInProgress(IProgressEvents progressEvents, BindCommandArgs bindingArgs) { this.OnBindingStarted(); ProgressNotificationListener progressListener = new ProgressNotificationListener(progressEvents, this.host.Logger); progressListener.MessageFormat = Strings.BindingSolutionPrefixMessageFormat; progressEvents.RunOnFinished(result => { progressListener.Dispose(); this.OnBindingFinished(bindingArgs, result == ProgressControllerResult.Succeeded); }); }
public ProgressNotificationListener(IProgressEvents progressEvents, ILogger logger) { if (progressEvents == null) { throw new ArgumentNullException(nameof(progressEvents)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } this.progressEvents = progressEvents; this.logger = logger; this.progressEvents.StepExecutionChanged += this.OnStepExecutionChanged; }
public ProgressNotificationListener(IServiceProvider serviceProvider, IProgressEvents progressEvents) { if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } if (progressEvents == null) { throw new ArgumentNullException(nameof(progressEvents)); } this.serviceProvider = serviceProvider; this.progressEvents = progressEvents; this.progressEvents.StepExecutionChanged += this.OnStepExecutionChanged; }
/// <summary> /// The <paramref name="onFinishedAction"/> will be called once when the <paramref name="controller"/> /// will finish by invoking <see cref="IProgressEvents.Finished"/>. /// </summary> /// <param name="controller">Required. <seealso cref="IProgressController"/></param> /// <param name="onFinishedAction">Required. The action that will be invoked with the finished <see cref="ProgressControllerResult"/></param> /// <remarks>This code will not cause memory leaks due to event registration</remarks> public static void RunOnFinished(this IProgressEvents controller, Action <ProgressControllerResult> onFinishedAction) { if (controller == null) { throw new ArgumentNullException(nameof(controller)); } if (onFinishedAction == null) { throw new ArgumentNullException(nameof(onFinishedAction)); } EventHandler <ProgressControllerFinishedEventArgs> onFinished = null; onFinished = (o, e) => { controller.Finished -= onFinished; onFinishedAction.Invoke(e.Result); }; controller.Finished += onFinished; }
internal ProgressObserver(IServiceProvider serviceProvider, IProgressVisualizer host, IProgressEvents progressEvents, ProgressControllerViewModel state) { // Event registration must be on the UI thread ThreadHelper.ThrowIfNotOnUIThread(); if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } if (host == null) { throw new ArgumentNullException(nameof(host)); } if (progressEvents == null) { throw new ArgumentNullException(nameof(progressEvents)); } Debug.Assert(progressEvents.Steps != null, "Expected to be initialized"); this.serviceProvider = serviceProvider; this.host = host; this.progressEvents = progressEvents; this.progressEvents.Started += this.ControllerStarted; this.progressEvents.Finished += this.ControllerFinished; this.progressEvents.StepExecutionChanged += this.OnStepExecutionChanged; this.progressEvents.CancellationSupportChanged += this.OnCancellationSupportChanged; this.viewModelRoot = state ?? new ProgressControllerViewModel(); this.InitializeStepViewModels(); this.host.ViewModel = this.viewModelRoot; }
public static ProgressObserver StartObserving(IServiceProvider serviceProvider, IProgressEvents progressEvents, IProgressVisualizer visualizer) { return StartObserving(serviceProvider, progressEvents, visualizer, null); }
public static ProgressObserver StartObserving(IServiceProvider serviceProvider, IProgressEvents progressEvents, IProgressVisualizer visualizer, ProgressControllerViewModel state) { if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } if (progressEvents == null) { throw new ArgumentNullException(nameof(progressEvents)); } if (visualizer == null) { throw new ArgumentNullException(nameof(visualizer)); } CheckSupportedProgressEvents(progressEvents); ProgressObserver observer = CreateAndConfigureInstance(serviceProvider, visualizer, progressEvents, null, state); Debug.Assert(observer != null, "Failed to create observer on the UI thread"); return(observer); }
private void DebugOnly_MonitorProgress(IProgressEvents progress) { progress.RunOnFinished(r => VsShellUtils.WriteToSonarLintOutputPane(this.host, "DEBUGONLY: Binding workflow finished, Execution result: {0}", r)); }
public static ProgressObserver StartObserving(IServiceProvider serviceProvider, IProgressEvents progressEvents, IProgressVisualizer visualizer, ProgressControllerViewModel state) { if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } if (progressEvents == null) { throw new ArgumentNullException(nameof(progressEvents)); } if (visualizer == null) { throw new ArgumentNullException(nameof(visualizer)); } CheckSupportedProgressEvents(progressEvents); ProgressObserver observer = CreateAndConfigureInstance(serviceProvider, visualizer, progressEvents, null, state); Debug.Assert(observer != null, "Failed to create observer on the UI thread"); return observer; }
private static ProgressObserver CreateAndConfigureInstance(IServiceProvider serviceProvider, IProgressVisualizer visualizer, IProgressEvents progressEvents, ICommand cancelCommand, ProgressControllerViewModel state) { return VsThreadingHelper.RunInline(serviceProvider, VsTaskRunContext.UIThreadNormalPriority, () => { ProgressObserver returnValue = new ProgressObserver(serviceProvider, visualizer, progressEvents, state); returnValue.CancelCommand = cancelCommand; return returnValue; }, null); }
public static ProgressObserver StartObserving(IServiceProvider serviceProvider, IProgressEvents progressEvents) { return StartObserving(serviceProvider, progressEvents, new WpfWindowProgressVisualizer()); }
private static ProgressObserver CreateAndConfigureInstance(IServiceProvider serviceProvider, IProgressVisualizer visualizer, IProgressEvents progressEvents, ICommand cancelCommand, ProgressControllerViewModel state) { return(VsThreadingHelper.RunInline(serviceProvider, VsTaskRunContext.UIThreadNormalPriority, () => { ProgressObserver returnValue = new ProgressObserver(serviceProvider, visualizer, progressEvents, state); returnValue.CancelCommand = cancelCommand; return returnValue; }, null)); }
private void DebugOnly_MonitorProgress(IProgressEvents progress) { progress.RunOnFinished(r => this.host.Logger.WriteLine("DEBUGONLY: Connect workflow finished, Execution result: {0}", r)); }
private void DebugOnly_MonitorProgress(IProgressEvents progress) { progress.RunOnFinished(r => VsShellUtils.WriteToSonarLintOutputPane(this.host, "DEBUGONLY: Connect workflow finished, Execution result: {0}", r)); }
public static ProgressObserver StartObserving(IServiceProvider serviceProvider, IProgressEvents progressEvents) { return(StartObserving(serviceProvider, progressEvents, new WpfWindowProgressVisualizer())); }
public static ProgressObserver StartObserving(IServiceProvider serviceProvider, IProgressEvents progressEvents, IProgressVisualizer visualizer) { return(StartObserving(serviceProvider, progressEvents, visualizer, null)); }