예제 #1
0
        public RpcClient(Uri baseUrl, AuthenticationHeaderValue authHeaderValue = null,
                         JsonSerializerSettings jsonSerializerSettings          = null, HttpClientHandler httpClientHandler = null, ILog log = null)
        {
            _baseUrl = baseUrl;

            if (authHeaderValue == null)
            {
                authHeaderValue = UserAuthentication.FromUri(baseUrl)?.GetBasicAuthenticationHeaderValue();
            }

            _authHeaderValue = authHeaderValue;

            if (jsonSerializerSettings == null)
            {
                jsonSerializerSettings = DefaultJsonSerializerSettingsFactory.BuildDefaultJsonSerializerSettings();
            }

            _jsonSerializerSettings = jsonSerializerSettings;
            _httpClientHandler      = httpClientHandler;
            _log = log;

#if NETCOREAPP2_1 || NETCOREAPP3_1
            _httpClient        = CreateNewHttpClient();
            _rotateHttpClients = false;
#else
            CreateNewRotatedHttpClient();
#endif
        }
예제 #2
0
 public SimpleRpcClient(Uri baseUrl, HttpClient httpClient,
                        JsonSerializerSettings jsonSerializerSettings = null)
 {
     if (jsonSerializerSettings == null)
     {
         jsonSerializerSettings = DefaultJsonSerializerSettingsFactory.BuildDefaultJsonSerializerSettings();
     }
     _jsonSerializerSettings = jsonSerializerSettings;
     _httpClient             = httpClient;
     _httpClient.BaseAddress = baseUrl;
 }
예제 #3
0
        public RpcClient(Uri baseUrl, HttpClient httpClient, AuthenticationHeaderValue authHeaderValue = null,
                         JsonSerializerSettings jsonSerializerSettings = null, ILog log = null)
        {
            _baseUrl = baseUrl;

            if (authHeaderValue == null)
            {
                authHeaderValue = UserAuthentication.FromUri(baseUrl)?.GetBasicAuthenticationHeaderValue();
            }

            _authHeaderValue = authHeaderValue;
            if (jsonSerializerSettings == null)
            {
                jsonSerializerSettings = DefaultJsonSerializerSettingsFactory.BuildDefaultJsonSerializerSettings();
            }
            _jsonSerializerSettings = jsonSerializerSettings;
            _log = log;
            InitialiseHttpClient(httpClient);
            _httpClient        = httpClient;
            _rotateHttpClients = false;
        }