async Task CheckServerSourceAsync(RemoteServerPlatform platform) { try { await asyncManager.SwitchToBackground(); if (platform == RemoteServerPlatform.Unknown) { return; } //if (!solutionState.ContainProjects (platform)) { // return; //} var isActive = false; var source = serverSourceManager.GetSource(platform, out isActive); if (!isActive) { serverSourceManager.AddSource(source); } } catch (Exception ex) { //Add tracing } }
async Task DisconnectAsync(RemoteServerPlatform platform, bool unregisterServerSource = false) { try { await asyncManager.SwitchToBackground(); if (platform == RemoteServerPlatform.Unknown) { return; } var isActive = false; var source = serverSourceManager.GetSource(platform, out isActive); if (!isActive) { return; } if (unregisterServerSource) { serverSourceManager.RemoveSource(platform); } var server = source.GetServer(); await server .DisconnectAsync() .ConfigureAwait(continueOnCapturedContext: false); } catch (Exception ex) { //Add tracing } }
async Task TryConnectAsync(RemoteServerPlatform platform) { try { await asyncManager.SwitchToBackground(); if (platform == RemoteServerPlatform.Unknown) { return; } //if (!solutionState.ContainProjects (platform)) { // return; //} await CheckServerSourceAsync(platform) .ConfigureAwait(continueOnCapturedContext: false); var source = serverSourceManager .ActiveSources .FirstOrDefault(s => s.Platform == platform); var server = source.GetServer(); var connectAutomatically = default(bool); connectionTypes.TryGetValue(server.Platform, out connectAutomatically); if (!connectAutomatically) { return; } if (server.IsConnected) { await server .StartAgentsAsync() .ConfigureAwait(continueOnCapturedContext: false); } else { await server .TryConnectAsync() .ConfigureAwait(continueOnCapturedContext: false); } } catch (Exception ex) { //Add tracing } }
public void Configure(RemoteServerPlatform platform, bool connectAutomatically) { var currentConnectionType = default(bool); if (connectionTypes.TryGetValue(platform, out currentConnectionType)) { if (currentConnectionType == false) { connectionTypes.TryUpdate(platform, connectAutomatically, currentConnectionType); } } else { connectionTypes.TryAdd(platform, connectAutomatically); } }