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

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

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

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