using System.IO.Abstractions;
using Valg.EVA.Skanning.ContainerExtensions;
using Valg.EVA.Skanning.UserInterfaceElements.UserSettingWindow;
using Unity;
using Unity.Lifetime;
using Valg.Eva.Skanning.Scan.Presentation.BoxInfo;
using Valg.Eva.Skanning.Scan.Presentation.MainWindow;
using Valg.Eva.Skanning.Scan.Presentation.ReadSoftModel;
using Valg.Eva.Skanning.Scan.Presentation.ReadSoftModel.FieldValidators;
using Valg.Eva.Skanning.Scan.Presentation.RegisterBarcode;
using Valg.Eva.Skanning.Scan.Presentation.RegisterBarcode.Barcode;
using Valg.Eva.Skanning.Scan.Presentation.ScanInProgress;
using Valg.EVA.Skanning.Scan.Presentation.ReadSoftModel.FieldValidators;
using Valg.EVA.Skanning.Scan.Presentation.ScannerQuality;
using Valg.EVA.Skanning.ServicesModel.ElectionConfig.Model;

namespace Valg.Eva.Skanning.Scan.Presentation
{
    public class UnityInstaller : IUnityInstaller
    {
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
        public void Install(IUnityContainer unityContainer)
        {
            unityContainer.RegisterType<IMainWindow, MainWindow.MainWindow>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<ScanFormFinishedEventHandler>();
            unityContainer.RegisterType<IWindowHider, WindowHider>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<IMainWindowViewModel, MainWindow.MainWindowViewModel>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<IBoxInfoViewModel, BoxInfoViewModel>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<IRegisterBarcodeControl, RegisterBarcodeControl>();
            unityContainer.RegisterType<IRegisterBarcodeViewModel, RegisterBarcodeViewModel>();
            unityContainer.RegisterType<IScannerQualityViewModel, ScannerQualityViewModel>();
            unityContainer.RegisterType<DatabaseQuerier>();
            unityContainer.RegisterType<SaveDataFailedViewModel>();
            unityContainer.RegisterType<BoxIsDeletedDuringScanViewModel>();
            unityContainer.RegisterType<PaperJamViewModel>();
            unityContainer.RegisterType<UnspecificReadsoftErrorViewModel>();
            unityContainer.RegisterType<NoPaperInFeederViewModel>();
            unityContainer.RegisterType<BatchInUseForJobViewModel>();

            unityContainer.RegisterType<IFieldValidator, BallotIdFieldValidator>("BallotIdFieldValidator");
            unityContainer.RegisterType<IFieldValidator, BallotNoFieldValidator>("BallotNoFieldValidator");
            unityContainer.RegisterType<IFieldValidator, CandidateFieldValidator>("CandidateFieldValidator");
            unityContainer.RegisterType<IFieldValidator, CandidateRenumberFieldValidator>("CaRenumberFieldValidator");
            unityContainer.RegisterType<IFieldValidator, MarkDecrFieldValidator>("MarkDecrFieldValidator");
            unityContainer.RegisterType<IFieldValidator, MarkIncrFieldValidator>("MarkIncrFieldValidator");
            unityContainer.RegisterType<IFieldValidator, PartyWriteFieldValidator>("PartyWriteFieldValidator");
            unityContainer.RegisterType<IFieldValidator, RefOptFieldValidator>("RefOptFieldValidator");
            unityContainer.RegisterType<IFieldValidator, StampFieldValidator>("StampFieldValidator");
            unityContainer.RegisterType<IFieldValidator, MultipleStampsFieldValidator>("MultipleStampsFieldValidator");
            unityContainer.RegisterType<IFieldValidator, AffiliationNameFieldValidator>("AffiliationNameFieldValidator");
            unityContainer.RegisterType<IFieldValidator, ContestNameFieldValidator>("ContestNameFieldValidator");
            unityContainer.RegisterType<IScannedBallotPaperMapper, ScannedBallotPaperMapper>(ContainerLifetimes.CreateContainerControlledLifetimeManager());

            unityContainer.RegisterType<IFileSystem, FileSystem>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<IBarcodeValidator, BarcodeValidator>(ContainerLifetimes.CreateContainerControlledLifetimeManager());

            unityContainer.RegisterType<IMainWindowInitializer, MainWindowInitializer>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
        }
    }
}
