public AzPredictorSurveyHelper(IPowerShellRuntime powerShellRuntime)
        {
            var host = powerShellRuntime.HostName;

            if ((host.IndexOf("Visual Studio Code", StringComparison.InvariantCultureIgnoreCase) == -1) &&
                !string.Equals(host, AzPredictorConstants.MockPSHostName, StringComparison.Ordinal))
            {
                var promptMessageScript = @"
                    if ([Microsoft.Azure.PowerShell.Tools.AzPredictor.AzPredictorData]::ShowSurveyOnIdle) {
                        [Microsoft.Azure.PowerShell.Tools.AzPredictor.AzPredictorData]::ShowSurveyOnIdle = $False
                        Write-Host ''
                        Write-Host ''; Write-Host `Survey: -ForegroundColor $Host.PrivateData.VerboseBackgroundColor -BackgroundColor $host.PrivateData.VerboseForegroundColor -NoNewLine; Write-Host ' How was your experience using the Az Predictor module?'
                        Write-Host ''
                        Write-Host 'Run ' -NoNewline; Write-Host Open-AzPredictorSurvey -ForegroundColor $Host.PrivateData.VerboseBackgroundColor -BackgroundColor $host.PrivateData.VerboseForegroundColor -NoNewline; Write-Host ' to give us your feedback.'
                        Write-Host ''
                        Write-Host '(Use ""Ctrl + C"" to return to the prompt)'
                    }";

                ScriptBlock scriptBlock = ScriptBlock.Create(promptMessageScript);
                _powerShellEventManager = powerShellRuntime.ConsoleRuntime.Runspace.Events;
                _idleEventSubscriber    = _powerShellEventManager.SubscribeEvent(source: null,
                                                                                 eventName: null,
                                                                                 sourceIdentifier: PSEngineEvent.OnIdle,
                                                                                 data: null,
                                                                                 action: scriptBlock,
                                                                                 supportEvent: true,
                                                                                 forwardEvent: false);

                _promptDelayTimer          = new Timer(TimeSpan.FromSeconds(1).TotalMilliseconds);
                _promptDelayTimer.Elapsed += OnPromptDelayTimer;
            }
        }
Пример #2
0
 public GenericPlayController(
     GameDatabase db,
     Game game,
     IPowerShellRuntime scriptRuntime,
     IPlayniteAPI playniteApi) : base(game)
 {
     execContext        = SynchronizationContext.Current;
     database           = db;
     this.scriptRuntime = scriptRuntime;
     this.playniteApi   = playniteApi;
 }
Пример #3
0
 public AzContext(IPowerShellRuntime powerShellRuntime) => _powerShellRuntime