Добавил DI, основные классы создаются через вбрасывание зависимостей через конструктор
This commit is contained in:
@@ -5,19 +5,19 @@ using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using ZaoBot.Config;
|
||||
|
||||
namespace ZaoBot.OpenHab
|
||||
{
|
||||
class OpenHabClient
|
||||
{
|
||||
private string url;
|
||||
private string token;
|
||||
private string token = "";
|
||||
HttpClient http = new HttpClient();
|
||||
|
||||
public OpenHabClient(string url, string token = "")
|
||||
public OpenHabClient(IConfig config)
|
||||
{
|
||||
this.url = url;
|
||||
this.token = token;
|
||||
this.url = config.Data.RootElement.GetProperty("openhab_url").GetString();
|
||||
if (!string.IsNullOrEmpty(token))
|
||||
{
|
||||
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", token + ":");
|
||||
|
||||
Reference in New Issue
Block a user