public ClientSettings(IServerHttpCredentials credentials) { if (credentials == null) { throw new ArgumentNullException(nameof(credentials)); } Credentials = credentials; }
private async Task <T> ExecuteAsync <T>(Func <Client, CancellationToken, Task <T> > send, IServerHttpCredentials credentials = null) where T : class { try { Log(null); CancellationTokenSource = new CancellationTokenSource(); string url = ServerUrlTextBox.Text; var client = new Client(url, new ClientSettings(credentials ?? GetCredentials())) { Log = Log }; try { return(await send(client, CancellationTokenSource.Token)); } finally { client.Dispose(); DisposeCanncellationTokenSource(); } } catch (Exception ex) { if (ErrorTextBox.Text == string.Empty) { ErrorTextBox.Text = ex.ToString(); } DisposeCanncellationTokenSource(); } return(default(T)); }