Пример #1
0
        /// <summary>
        /// Determines whether this Connection instance can connect to the specified connection Uri.
        /// </summary>
        /// <param name="connection">The connection instanace being tested.</param>
        /// <returns>The boolean result from the asynchronous operation.</returns>
        public async Task <bool> CanConnect(Connection connection)
        {
            try
            {
                var client = new JsonClient(connection.Username, connection.Password);
                connection.JsonWebToken = client.GetJsonWebToken(connection.Uri);

                _log.Debug("Token connection test passed");
                return(await Task.FromResult(true));
            }
            catch (Exception ex)
            {
                _log.Error("Token connection test failed: {0}", ex);
                return(await Task.FromResult(false));
            }
        }