using Valg.EVA.Skanning.ContainerExtensions;
using Valg.EVA.Skanning.Tools;
using Unity;
using Valg.EVA.Skanning.Services.Count;
using Valg.EVA.Skanning.Services.CountResult;
using Valg.EVA.Skanning.Services.EmergencyMode;
using Valg.EVA.Skanning.Services.InstallClientCertificate;
using Valg.EVA.Skanning.Services.Scan;
using Valg.EVA.Skanning.Services.SystemServices;
using Valg.EVA.Skanning.Services.SystemSettings;
using Valg.EVA.Skanning.Services.TransferCounting;
using Valg.EVA.Skanning.Services.Verification;

namespace Valg.EVA.Skanning.Services
{
    public class UnityInstaller : IUnityInstaller
    {
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
        public void Install(IUnityContainer unityContainer)
        {
            unityContainer.RegisterType<ISystemSettingsService, SystemSettingsService>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<ICountingService, CountingService>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<IVerificationService, VerificationService>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<IBallotPaperToVerifyResolver, BallotPaperToVerifyResolver>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<IScanService, ScanService>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<ISystemService, SystemService>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<ICountingResultService, CountingResultService>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<CountingResultGenerator>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<CountingEmlGenerator>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<ITiffConverter, TiffConverter>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<IWriteInFieldGenerator, WriteInFieldGenerator>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<ITransferCountingService, TransferCountingService>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<IEmergencyModeService, EmergencyModeService>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<BallotIdValidator>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<ElectionConfigEndpoint>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<IInstallClientCertificateService, InstallClientCertificateService>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
        }
    }
}
