コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="urls"></param>
        /// <param name="token">Throws a <see cref="T:System.OperationCanceledException" /> if this token has had cancellation requested.</param>
        /// <returns></returns>
        /// <exception cref="T:System.OperationCanceledException">The token has had cancellation requested.</exception>
        public string TryConnectTo(List <string> urls, CancellationToken token)
        {
            _urls = urls;

            foreach (var url in urls)
            {
                try
                {
                    var connectedTo = _connectionManager.ConnectTo(url, token);
                    if (string.IsNullOrEmpty(connectedTo))
                    {
                        continue;
                    }

                    if (TryLoadChainId(token))
                    {
                        return(url);
                    }

                    if (_connectionManager.IsConnected)
                    {
                        _connectionManager.Disconnect();
                    }
                }
                catch
                {
                    //todo nothing
                }
            }

            return(string.Empty);
        }