using JiShe.CollectBus.Protocol.Interfaces;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.Modularity;

namespace JiShe.CollectBus.Protocol.Test
{
    public class JiSheCollectBusTestProtocolModule : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            Console.WriteLine("TestProtocolPlugin ConfigureServices");
            context.Services.AddKeyedSingleton<IProtocolPlugin, TestProtocolPlugin>(nameof(TestProtocolPlugin));
        }

        public override async Task OnApplicationInitializationAsync(ApplicationInitializationContext context)
        {
            Console.WriteLine("TestProtocolPlugin OnApplicationInitializationAsync");
            var protocol = context.ServiceProvider.GetRequiredKeyedService<IProtocolPlugin>(nameof(TestProtocolPlugin));
            await protocol.LoadAsync();
        }

        public override void OnApplicationShutdown(ApplicationShutdownContext context)
        {
            Console.WriteLine("TestProtocolPlugin OnApplicationShutdown");
            base.OnApplicationShutdown(context);
        }
    }
}
