private HttpClient GetClient()

in sdk/Common/Communication/netcore/ServiceClientNewImpl.cs [283:347]


        private HttpClient GetClient()
        {
            if (_httpClientSelf != null)
            {
                return _httpClientSelf;
            }

            bool notUseProxy = string.IsNullOrEmpty(Configuration.ProxyHost);

            if (notUseProxy)
            {
                if (_httpClientNoProxy == null)
                {
                    lock (_clientLock)
                    {
                        if (_httpClientNoProxy == null)
                        {
                            _configurationNoProxy = Configuration.Clone() as ClientConfiguration;
                            _httpClientNoProxy = Create(false);
                        }
                    }
                } 
            }
            else
            {
                if (_httpClient == null)
                {
                    lock (_clientLock)
                    {
                        if (_httpClient == null)
                        {
                            _configuration = Configuration.Clone() as ClientConfiguration;
                            _httpClient = Create(true);
                        }
                    }
                } 
            }

            if (notUseProxy)
            {
                if (CanReuseHttpClient(_configurationNoProxy, Configuration))
                {
                    _httpClientSelf = _httpClientNoProxy;
                }
            }
            else
            {
                if (CanReuseHttpClient(_configuration, Configuration))
                {
                    _httpClientSelf = _httpClient;
                }
            }

            if (_httpClientSelf == null)
            {
                lock (_clientLock)
                {
                    if (_httpClientSelf == null)
                    {
                        _httpClientSelf = Create(!notUseProxy);
                    }
                }
            }
            return _httpClientSelf;
        }