Добавил DI, основные классы создаются через вбрасывание зависимостей через конструктор

This commit is contained in:
ftc
2024-01-20 16:56:44 +03:00
parent 77d563d500
commit 2a8348df44
7 changed files with 75 additions and 24 deletions
+4 -3
View File
@@ -8,6 +8,7 @@ using System.Threading.Tasks;
using Telegram.Bot;
using Telegram.Bot.Args;
using Telegram.Bot.Types.ReplyMarkups;
using ZaoBot.Config;
namespace ZaoBot
{
@@ -20,15 +21,15 @@ namespace ZaoBot
bool shouldRestart = false;
public BotService(JsonDocument config)
public BotService(IConfig config, OpenHab.OpenHabClient openhab)
{
this.config = config;
this.config = config.Data;
this.openhab = openhab;
}
public void Run()
{
var token = config.RootElement.GetProperty("token").GetString();
openhab = new OpenHab.OpenHabClient(config.RootElement.GetProperty("openhab_url").GetString());
while (true)
{
shouldRestart = false;