public static IMapper GetMapper()
        => new MapperConfiguration(cfg =>
        {
            cfg.CreateMap <ApplicationPool, ApplicationPoolGetDto>()
            .ForMember(dm => dm.Status, o => o.MapFrom(sm => sm.State))
            .ForMember(dm => dm.Identity, o => o.MapFrom(sm => sm.ProcessModel.IdentityType))
            .ForMember(dm => dm.Applications,
                       o => o.MapFrom(sm => ApplicationPoolUtils.GetNumberOfApplicationPoolApplications(sm.Name)));

            cfg.CreateMap <ApplicationPool, ApplicationPoolEditablePropertiesDto>()
            .ForMember(dm => dm.Identity, o => o.MapFrom(sm => sm.ProcessModel.IdentityType));

            cfg.CreateMap <App, ApplicationGetDto>()
            .ForMember(dm => dm.Name, o => o.MapFrom(sm => ApplicationUtils.ConvertPathToName(sm.Path)))
            .ForMember(dm => dm.PhysicalPath,
                       o => o.MapFrom(sm => sm.VirtualDirectories["/"].PhysicalPath))
            .ForMember(dm => dm.ApplicationPoolStatus,
                       o => o.MapFrom(sm =>
                                      ApplicationPoolUtils.GetApplicationPoolStatus(sm.ApplicationPoolName)));

            cfg.CreateMap <App, ApplicationEditablePropertiesDto>()
            .ForMember(dm => dm.Name, o => o.MapFrom(sm => ApplicationUtils.ConvertPathToName(sm.Path)))
            .ForMember(dm => dm.PhysicalPath,
                       o => o.MapFrom(sm => sm.VirtualDirectories["/"].PhysicalPath));

            cfg.CreateMap <Build, BuildGetDto>();
        })
        .CreateMapper();
        public void Handle(AddApplicationPool command)
        {
            command.ThrowIfNull(command.Name);
            var applicationPool = _applicationPoolFacade.GetApplicationPool(command.Name);

            applicationPool.ThrowIfExists();
            var managedPipelineMode =
                ApplicationPoolUtils.ParseToEnumOrThrow <ManagedPipelineMode>(command.ManagedPipelineMode);

            _applicationPoolFacade.AddApplicationPool(command.Name, managedPipelineMode,
                                                      command.ManagedRuntimeVersion, command.AutoStart);
        }
        public void Handle(UpdateApplicationPool command)
        {
            command.ThrowIfNull(GetType().Name);
            var applicationPool = _applicationPoolFacade.GetApplicationPool(command.Name);

            applicationPool.ThrowIfNull(command.Name);
            var newApplicationPool = _applicationPoolFacade.GetApplicationPool(command.NewName);

            newApplicationPool.ThrowIfExists();
            applicationPool.Name = command.NewName;
            applicationPool.ManagedPipelineMode =
                ApplicationPoolUtils.ParseToEnumOrThrow <ManagedPipelineMode>(command.ManagedPipelineMode);
            applicationPool.ManagedRuntimeVersion     = command.ManagedRuntimeVersion;
            applicationPool.ProcessModel.IdentityType =
                ApplicationPoolUtils.ParseToEnumOrThrow <ProcessModelIdentityType>(command.Identity);
            _applicationPoolFacade.UpdateApplicationPool();
        }