From 3ed00f732a284b5a3e96e52d4e3a71869135869b Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Mon, 26 Jun 2023 02:43:54 +0200 Subject: Dependency injection stuff --- MatrixRoomUtils.Bot/Program.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'MatrixRoomUtils.Bot/Program.cs') diff --git a/MatrixRoomUtils.Bot/Program.cs b/MatrixRoomUtils.Bot/Program.cs index e8a5b96..0e27286 100644 --- a/MatrixRoomUtils.Bot/Program.cs +++ b/MatrixRoomUtils.Bot/Program.cs @@ -1,6 +1,8 @@ // See https://aka.ms/new-console-template for more information using MatrixRoomUtils.Bot; +using MatrixRoomUtils.Bot.Interfaces; +using MatrixRoomUtils.Core.Extensions; using MatrixRoomUtils.Core.Services; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -16,6 +18,10 @@ var host = Host.CreateDefaultBuilder(args).ConfigureServices((_, services) => { ); services.AddScoped(); services.AddRoryLibMatrixServices(); + foreach (var commandClass in new ClassCollector().ResolveFromAllAccessibleAssemblies()) { + Console.WriteLine($"Adding command {commandClass.Name}"); + services.AddScoped(typeof(ICommand), commandClass); + } services.AddHostedService(); }).UseConsoleLifetime().Build(); -- cgit 1.5.1