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

namespace JiShe.CollectBus.Protocol.T6452007
{
    public class JiSheCollectBusProtocolT6452007Module : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            context.Services.AddKeyedSingleton<IProtocolPlugin, T6452007ProtocolPlugin>(nameof(T6452007ProtocolPlugin));
        }

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

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