using Autofac;
using Autofac.Extensions.DependencyInjection;
using e_suite.MessageProcessor.DependencyInjection;
using e_suite.MessageProcessor.QueueProcessor;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

/*Console.WriteLine("Initialising");

var containerBuilder = new ContainerBuilder();
var coreRegistrationModule = new CoreRegistrationModule();
await coreRegistrationModule.Load(containerBuilder);
var container = containerBuilder.Build();

Console.WriteLine("Starting Message Processor");
using var queueProcessor = container.Resolve<QueueProcessor>();

Console.WriteLine("Waiting for messages.");
Console.WriteLine("Press [enter] to stop and exit.");
Console.ReadLine();*/

var hostBuilder = new HostBuilder()
    .UseServiceProviderFactory(new AutofacServiceProviderFactory())
    .ConfigureContainer<ContainerBuilder>(builder =>
        {
            builder.RegisterModule(new CoreRegistrationModule());
        }
    )
    // Add configuration, logging, ...
    .ConfigureServices((hostContext, services) =>
    {
        // Add your services with dependency injection.
        services
            .AddLogging(loggerBuilder =>
            {
                loggerBuilder.ClearProviders();
                loggerBuilder.AddConsole();
            });

        services.AddHostedService<QueueProcessorService>();
    });

hostBuilder.Build().Run();