Exemple #1
0
        public ArbitraryRestClient()
        {
            HttpClient _httpClient;

            _serviceName = typeof(TInterface).Name.TrimStart('I').Replace("appservice", "", StringComparison.OrdinalIgnoreCase);

            if (typeof(TInterface).IsInterface)
            {
                var attrs = typeof(TInterface).GetCustomAttributes(false);
                var baseUriOrServiceName = attrs.First(at => at.GetType() == typeof(BaseUriAttribute)) as BaseUriAttribute;
                if (baseUriOrServiceName.IsServiceName)
                {
                    _httpClient = RestClientFactory.GetOrAddLoadBalancedClient(baseUriOrServiceName.BaseUriOrServiceName);
                }
                else
                {
                    _httpClient = RestClientFactory.CreateWithBaseAddress(baseUriOrServiceName.BaseUriOrServiceName);
                }
                _generalRestClient = new GeneralRestClient()
                {
                    HttpClient = _httpClient
                }.WithJwt().WithTenency().WithConfigCenterKey();
            }
        }