public int AddPort(IDebugPortRequest2 request, out IDebugPort2 port) { var debugSessionMetrics = new DebugSessionMetrics(_metrics); debugSessionMetrics.UseNewDebugSessionId(); var actionRecorder = new ActionRecorder(debugSessionMetrics); port = null; if (request.GetPortName(out string gameletIdOrName) != VSConstants.S_OK) { return(VSConstants.E_FAIL); } var action = actionRecorder.CreateToolAction(ActionType.GameletGet); var gameletClient = _gameletClientFactory.Create(_cloudRunner.Intercept(action)); var gameletTask = _cancelableTaskFactory.Create( "Querying instance...", async() => await gameletClient.LoadByNameOrIdAsync(gameletIdOrName)); try { gameletTask.RunAndRecord(action); } catch (CloudException e) { Trace.WriteLine(e.ToString()); _dialogUtil.ShowError(e.Message); return(VSConstants.S_OK); } var debugPort = _debugPortFactory.Create(gameletTask.Result, this, debugSessionMetrics.DebugSessionId); _ports.Add(debugPort); port = debugPort; return(VSConstants.S_OK); }
public void SetUp() { gameletClient = Substitute.For <IGameletClient>(); gameletClientFactory = Substitute.For <GameletClient.Factory>(); gameletClientFactory.Create(Arg.Any <ICloudRunner>()).Returns(gameletClient); cloudRunner = Substitute.For <ICloudRunner>(); sshKeyLoader = Substitute.For <ISshKeyLoader>(); sshKnownHostsWriter = Substitute.For <ISshKnownHostsWriter>(); remoteCommand = Substitute.For <IRemoteCommand>(); sshManager = new SshManager(gameletClientFactory, cloudRunner, sshKeyLoader, sshKnownHostsWriter, remoteCommand); }
List <Gamelet> ListInstances() { try { var action = _actionRecorder.CreateToolAction(ActionType.GameletsList); var gameletClient = _gameletClientFactory.Create(_cloudRunner.Intercept(action)); var queryTask = _cancelableTaskFactory.Create( "Querying instances...", async() => await gameletClient.ListGameletsAsync(false)); if (!queryTask.RunAndRecord(action)) { return(null); } return(queryTask.Result); } catch (CloudException e) { Trace.Write("An exception was thrown while querying instances." + Environment.NewLine + e); GameletMessageTextBox.Text = ErrorStrings.FailedToRetrieveGamelets(e.Message); return(null); } }