Skip to content

Commit

Permalink
Merge pull request spring-io#664 from dmilov/bug/fix-for-663-remove-c…
Browse files Browse the repository at this point in the history
…onstructor-sideeffect

Fixes spring-io#663. Remove 'Configuration' constructor sideeffect
  • Loading branch information
HugoMario authored Jun 4, 2020
2 parents 4a1bc8f + 983536a commit b4f1c3d
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions src/main/resources/handlebars/csharp/Configuration.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ namespace {{packageName}}.Client
ApiKey = new {{^net35}}Concurrent{{/net35}}Dictionary<string, string>();
ApiKeyPrefix = new {{^net35}}Concurrent{{/net35}}Dictionary<string, string>();

// Setting Timeout has side effects (forces ApiClient creation).
Timeout = 100000;
}

Expand Down Expand Up @@ -236,15 +235,49 @@ namespace {{packageName}}.Client
/// </summary>
public virtual IDictionary<string, string> DefaultHeader { get; set; }
private int _timeout = 100000;
/// <summary>
/// Gets or sets the HTTP timeout (milliseconds) of ApiClient. Default to 100000 milliseconds.
/// </summary>
public virtual int Timeout
{
{{#netStandard}}get { return (int)ApiClient.RestClient.Timeout.GetValueOrDefault(TimeSpan.FromSeconds(0)).TotalMilliseconds; }
set { ApiClient.RestClient.Timeout = TimeSpan.FromMilliseconds(value); }{{/netStandard}}{{^netStandard}}
get { return ApiClient.RestClient.Timeout; }
set { ApiClient.RestClient.Timeout = value; }{{/netStandard}}
{{#netStandard}}get
{
if (_apiClient == null)
{
return _timeout;
} else
{
return (int)ApiClient.RestClient.Timeout.GetValueOrDefault(TimeSpan.FromSeconds(0)).TotalMilliseconds;
}
}
set
{
_timeout = value;
if (_apiClient != null)
{
ApiClient.RestClient.Timeout = TimeSpan.FromMilliseconds(_timeout);
}
}{{/netStandard}}{{^netStandard}}
get
{
if (_apiClient == null)
{
return _timeout;
}
else
{
return ApiClient.RestClient.Timeout;
}
}
set
{
_timeout = value;
if (_apiClient != null)
{
ApiClient.RestClient.Timeout = _timeout;
}
}{{/netStandard}}
}
/// <summary>
Expand Down

0 comments on commit b4f1c3d

Please sign in to comment.