using IWS5.Core;
using IWS5.Core.Enums;
using IWS5.Core.Helpers;
using IWS5.DatabaseAccess.Extensions;
using IWS5.Server.EventProcessors;
using IWS5.Services.Helpers;

namespace IWS5.Server.Extensions;

internal static class ServiceCollectionExtensions
{
    internal static IServiceCollection RegisterDependencies(this IServiceCollection services, IConfiguration configuration)
    {
        services.RegisterDatabaseAccess(configuration);

        services.AddTransient<IMessageProcessor, MessageProcessor>();

        services.AddKeyedScoped<IEventProcessor, StartProcessor>(ATEventType.Start);
        services.AddKeyedScoped<IEventProcessor, StopProcessor>(ATEventType.Stop);
        services.AddKeyedScoped<IEventProcessor, QueueProcessor>(ATEventType.Queue);
        services.AddKeyedScoped<IEventProcessor, InboxProcessor>(ATEventType.User);
        services.AddKeyedScoped<IEventProcessor, TrackingProcessor>(ATEventType.Tracking);
        services.AddKeyedScoped<IEventProcessor, MailProcessor>(ATEventType.Mail);
        services.AddKeyedScoped<IEventProcessor, DecisionProcessor>(ATEventType.Decision);
        services.AddKeyedScoped<IEventProcessor, CodeProcessor>(ATEventType.Code);
        services.AddKeyedScoped<IEventProcessor, TimerProcessor>(ATEventType.Timer);
        services.AddKeyedScoped<IEventProcessor, SetDataProcessor>(ATEventType.SetData);
        services.AddKeyedScoped<IEventProcessor, RuleProcessor>(ATEventType.Rule);
        services.AddKeyedScoped<IEventProcessor, ExportProcessor>(ATEventType.Export);
        services.AddKeyedScoped<IEventProcessor, ConvertProcessor>(ATEventType.Convert);

        return services;
    }
}
