using System.Diagnostics.CodeAnalysis;
using Valg.EVA.Skanning.ContainerExtensions;
using Unity;
using Valg.EVA.Skanning.Commands.CreateCountingResult;
using Valg.EVA.Skanning.Commands.DeleteBoxCountingAndRegisterForScanAgain;
using Valg.EVA.Skanning.Commands.DeleteCounting;
using Valg.EVA.Skanning.Commands.DetectDuplicatesInCounting;
using Valg.EVA.Skanning.Commands.EmergencyMode;
using Valg.EVA.Skanning.Commands.RefreshUpdatedTimestampOnTransfer;
using Valg.EVA.Skanning.Commands.RegisterBox;
using Valg.EVA.Skanning.Commands.RegisterBoxAsEmpty;
using Valg.EVA.Skanning.Commands.ResolveBoxCountingDuplicates;
using Valg.EVA.Skanning.Commands.ResolveLockedBallots;
using Valg.EVA.Skanning.Commands.SaveBallotPaperVerifications;
using Valg.EVA.Skanning.Commands.SaveCombinedScanImage;
using Valg.EVA.Skanning.Commands.SaveInterpreterModifications;
using Valg.EVA.Skanning.Commands.SaveResultFileForTransfer;
using Valg.EVA.Skanning.Commands.SaveScannedBallotPaper;
using Valg.EVA.Skanning.Commands.SetBoxCompletelyScanned;
using Valg.EVA.Skanning.Commands.SetCountingLocked;
using Valg.EVA.Skanning.Commands.SetTransferFailed;
using Valg.EVA.Skanning.Commands.SetTransferSuccessful;
using Valg.EVA.Skanning.Commands.StartCounting;
using Valg.EVA.Skanning.Commands.StartScanning;
using Valg.EVA.Skanning.Commands.UpdateBallotPaperSeenStatus;
using Valg.EVA.Skanning.Commands.UpdateTransferState;

namespace Valg.EVA.Skanning.Commands
{
    public class UnityInstaller : IUnityInstaller
    {
        [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
        public void Install(IUnityContainer unityContainer)
        {
            unityContainer.RegisterType<ICommandDispatcher, CommandDispatcher>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<StartCountingCommandHandler>();
            unityContainer.RegisterType<RegisterBoxForCountingCommandHandler>();
            unityContainer.RegisterType<UpdateBallotPaperSeenStatusCommandHandler>();
            unityContainer.RegisterType<SaveScannedBallotPaperCommandHandler>();
            unityContainer.RegisterType<SaveBallotPaperVerificationsCommandHandler>();
            unityContainer.RegisterType<SaveInterpreterModificationsCommandHandler>();
            unityContainer.RegisterType<DeleteBoxCountingAndReregisterForScanningCommandHandler>();
            unityContainer.RegisterType<StartScanningCommandHandler>();
            unityContainer.RegisterType<SetBoxCompletelyScannedCommandHandler>();
            unityContainer.RegisterType<SetCountingLockedCommandHandler>();
            unityContainer.RegisterType<CreateCountingResultCommandHandler>();
            unityContainer.RegisterType<ResolveBoxCountingDuplicatesCommandHandler>();
            unityContainer.RegisterType<DetectDuplicatesInCountingCommandHandler>(ContainerLifetimes.CreateContainerControlledLifetimeManager());
            unityContainer.RegisterType<DeleteCountingCommandHandler>();
            unityContainer.RegisterType<RegisterBoxAsEmptyCommandHandler>();
            unityContainer.RegisterType<ResolveLockedBallotsCommandHandler>();
            unityContainer.RegisterType<CreateEmergencyModeCommandHandler>();
            unityContainer.RegisterType<StopEmergencyModeCommandHandler>();
            unityContainer.RegisterType<SaveCombinedScanImageCommandHandler>();
            unityContainer.RegisterType<SaveResultFileForTransferAsyncCommandHandler>();
            unityContainer.RegisterType<UpdateTransferStateAsyncCommandHandler>();
            unityContainer.RegisterType<SetTransferFailedAsyncCommandHandler>();
            unityContainer.RegisterType<SetTransferSuccessfulAsyncCommandHandler>();
            unityContainer.RegisterType<RefreshUpdatedTimestampOnTransferAsyncCommandHandler>();
            
            unityContainer.RegisterType<EnsureEmergencyModeFlagFilter>();
            unityContainer.RegisterType<ResetAllFieldsFilter>();
            unityContainer.RegisterType<FieldValueOperationsHelper>();
            unityContainer.RegisterType<UpdateBallotCommonFeaturesFilter>();
            unityContainer.RegisterType<UpdateBallotPersonalVotingFeaturesFilter>();
            unityContainer.RegisterType<UpdateBallotAggregatedValuesFilter>();
        }
    }
}
