@@ -39,8 +39,21 @@ namespace {{packageName}}.Client
3939 {
4040 private static readonly ConcurrentDictionary< int, Lazy< RestClient>> _restClientInstances = new ConcurrentDictionary< int, Lazy< RestClient>> ();
4141
42- public static RestClient GetRestClient(RestClientOptions clientOptions)
42+ public static RestClient GetRestClient(Configuration configuration, RestClientOptions clientOptions)
4343 {
44+ if (configuration.MerchantConfigDictionaryObj != null)
45+ {
46+ var merchantConfig = new MerchantConfig(configuration.MerchantConfigDictionaryObj);
47+
48+ ServicePointManager.DefaultConnectionLimit = int.Parse(merchantConfig.MaxConnectionPoolSize);
49+ ServicePointManager.MaxServicePointIdleTime = int.Parse(merchantConfig.KeepAliveTime);
50+ }
51+ else
52+ {
53+ ServicePointManager.DefaultConnectionLimit = int.Parse(Constants.DefaultMaxConnectionPoolSize);
54+ ServicePointManager.MaxServicePointIdleTime = int.Parse(Constants.DefaultKeepAliveTime);
55+ }
56+
4457 int hash = GetHashOfRestClientOptions(clientOptions);
4558
4659 if (!_restClientInstances.TryGetValue(hash, out Lazy<RestClient > lazyClient))
@@ -124,19 +137,6 @@ namespace {{packageName}}.Client
124137 {
125138 logger = LogManager.GetCurrentClassLogger();
126139 }
127-
128- if (Configuration.MerchantConfigDictionaryObj != null)
129- {
130- var merchantConfig = new MerchantConfig(Configuration.MerchantConfigDictionaryObj);
131-
132- ServicePointManager.DefaultConnectionLimit = int.Parse(merchantConfig.MaxConnectionPoolSize);
133- ServicePointManager.MaxServicePointIdleTime = int.Parse(merchantConfig.KeepAliveTime);
134- }
135- else
136- {
137- ServicePointManager.DefaultConnectionLimit = int.Parse(Constants.DefaultMaxConnectionPoolSize);
138- ServicePointManager.MaxServicePointIdleTime = int.Parse(Constants.DefaultKeepAliveTime);
139- }
140140 }
141141
142142 /// <summary >
@@ -387,7 +387,7 @@ namespace {{packageName}}.Client
387387
388388 // RestClient.ClearHandlers();
389389
390- var actualRestClient = RestClientFactory.GetRestClient(newRestClientOptions);
390+ var actualRestClient = RestClientFactory.GetRestClient(Configuration, newRestClientOptions);
391391
392392 // Logging Request Headers
393393 var headerPrintOutput = new StringBuilder();
@@ -559,7 +559,7 @@ namespace {{packageName}}.Client
559559
560560 var newRestClientOptions = GetRestClientOptions(Configuration);
561561
562- var actualRestClient = RestClientFactory.GetRestClient(newRestClientOptions);
562+ var actualRestClient = RestClientFactory.GetRestClient(Configuration, newRestClientOptions);
563563
564564 InterceptRequest(request);
565565 var response = await actualRestClient.Execute{ {^netStandard} }Async{ {/netStandard} }(request);
0 commit comments