Exemple #1
0
 internal Task <Window> LocateDteWindowAsync(string windowTitle)
 => IntegrationHelper.WaitForNotNullAsync(() => IntegrationHelper.RetryDteCall(() =>
 {
     foreach (Window window in _dte.Windows)
     {
         if (window.Caption.Equals(windowTitle, StringComparison.OrdinalIgnoreCase))
         {
             return(window);
         }
     }
     return(null);
 }));
        internal InteractiveWindow(VisualStudioInstance visualStudioInstance, string dteViewCommand, string dteWindowTitle, string createMethodName)
        {
            _visualStudioInstance = visualStudioInstance;
            _dteViewCommand       = dteViewCommand;

            // We have to show the window at least once to ensure the interactive service is loaded.
            ShowAsync(waitForPrompt: false).GetAwaiter().GetResult();

            var dteWindow = IntegrationHelper.WaitForNotNullAsync(() => _visualStudioInstance.Dte.LocateWindow(dteWindowTitle)).GetAwaiter().GetResult();

            IntegrationHelper.RetryRpcCall(() => dteWindow.Close());

            // Return a wrapper to the actual interactive window service that exists in the host process
            var integrationService = _visualStudioInstance.IntegrationService;

            _interactiveWindowWrapper = integrationService.Execute <InteractiveWindowWrapper>(typeof(InteractiveWindowWrapper), createMethodName);
        }