[OneBot] changed dependency injection logic of MessageService.cs and OperationService.cs

This commit is contained in:
Linwenxuan 2023-10-18 10:30:09 +08:00
parent 5c0e352bc5
commit b6e7567fe4
2 changed files with 7 additions and 4 deletions

View file

@ -35,9 +35,9 @@ public class LagrangeApp : IHost
{ {
_hostApp = host; _hostApp = host;
Logger = Services.GetRequiredService<ILogger<LagrangeApp>>(); Logger = Services.GetRequiredService<ILogger<LagrangeApp>>();
MessageService = new MessageService(Instance, WebService); MessageService = Services.GetRequiredService<MessageService>();
OperationService = new OperationService(Instance, WebService); OperationService = Services.GetRequiredService<OperationService>();
} }
public async Task StartAsync(CancellationToken cancellationToken = new()) public async Task StartAsync(CancellationToken cancellationToken = new())

View file

@ -1,7 +1,6 @@
using System.Text.Json; using System.Text.Json;
using Lagrange.Core.Common; using Lagrange.Core.Common;
using Lagrange.Core.Common.Interface; using Lagrange.Core.Common.Interface;
using Lagrange.OneBot.Core;
using Lagrange.OneBot.Core.Message; using Lagrange.OneBot.Core.Message;
using Lagrange.OneBot.Core.Network; using Lagrange.OneBot.Core.Network;
using Lagrange.OneBot.Core.Operation; using Lagrange.OneBot.Core.Operation;
@ -75,7 +74,11 @@ public sealed class LagrangeAppBuilder
public LagrangeAppBuilder ConfigureOneBot() public LagrangeAppBuilder ConfigureOneBot()
{ {
Services.AddSingleton<ContextBase, LiteDbContext>();
Services.AddSingleton<ILagrangeWebService, ReverseWSService>(); Services.AddSingleton<ILagrangeWebService, ReverseWSService>();
Services.AddSingleton<MessageService>();
Services.AddSingleton<OperationService>();
return this; return this;
} }