Remove ctor in LndSwaggerClient

This commit is contained in:
nicolas.dorier
2018-07-10 12:49:25 +09:00
parent 1a1078782e
commit 310a9a6d59
2 changed files with 14 additions and 17 deletions

View File

@@ -16,19 +16,7 @@ namespace BTCPayServer.Payments.Lightning.Lnd
private System.Lazy<Newtonsoft.Json.JsonSerializerSettings> _settings;
private string _baseUrl = "";
private System.Net.Http.HttpClient _httpClient;
public LndSwaggerClient(string baseUrl, System.Net.Http.HttpClient httpClient)
{
BaseUrl = baseUrl;
_httpClient = httpClient;
_settings = new System.Lazy<Newtonsoft.Json.JsonSerializerSettings>(() =>
{
var settings = new Newtonsoft.Json.JsonSerializerSettings();
UpdateJsonSerializerSettings(settings);
return settings;
});
}
private System.Net.Http.HttpClient _httpClient;
public string BaseUrl
{

View File

@@ -19,12 +19,21 @@ namespace BTCPayServer.Payments.Lightning.Lnd
public partial class LndSwaggerClient
{
public LndSwaggerClient(LndRestSettings settings)
: this(settings.Uri.AbsoluteUri.TrimEnd('/'), CreateHttpClient(settings))
{
_Settings = settings;
if (settings == null)
throw new ArgumentNullException(nameof(settings));
_LndSettings = settings;
_Authentication = settings.CreateLndAuthentication();
BaseUrl = settings.Uri.AbsoluteUri.TrimEnd('/');
_httpClient = CreateHttpClient(settings);
_settings = new System.Lazy<Newtonsoft.Json.JsonSerializerSettings>(() =>
{
var json = new Newtonsoft.Json.JsonSerializerSettings();
UpdateJsonSerializerSettings(json);
return json;
});
}
LndRestSettings _Settings;
LndRestSettings _LndSettings;
LndAuthentication _Authentication;
partial void PrepareRequest(HttpClient client, HttpRequestMessage request, string url)
@@ -64,7 +73,7 @@ namespace BTCPayServer.Payments.Lightning.Lnd
internal HttpClient CreateHttpClient()
{
return LndSwaggerClient.CreateHttpClient(_Settings);
return LndSwaggerClient.CreateHttpClient(_LndSettings);
}
internal T Deserialize<T>(string str)