using Abp.AutoMapper;
using Abp.Modules;
using Abp.Reflection.Extensions;
using MineTec.ProManager.Authorization;
using MineTec.ProManager.Monitoring;
using MineTec.ProManager.Notifications;
using MineTec.ProManager.Organizations;
using MineTec.ProManager.Resource;
using MineTec.ProManager.Social;
using MineTec.ProManager.MultiTenancy;
using MineTec.ProManager.TaskCenter;

namespace MineTec.ProManager
{
    [DependsOn(
        typeof(ProManagerCoreModule),
        typeof(AbpAutoMapperModule))]
    public class ProManagerApplicationModule : AbpModule
    {
        public override void PreInitialize()
        {
            // AutoMapper
            Configuration.Modules.AbpAutoMapper().Configurators.Add(AuthorizationMapper.CreateMappings);
            Configuration.Modules.AbpAutoMapper().Configurators.Add(OrganizationMapper.CreateMappings);
            Configuration.Modules.AbpAutoMapper().Configurators.Add(SocialMapper.CreateMappings);
            Configuration.Modules.AbpAutoMapper().Configurators.Add(NotificationMapper.CreateMappings);
            Configuration.Modules.AbpAutoMapper().Configurators.Add(MonitoringMapper.CreateMappings);
            Configuration.Modules.AbpAutoMapper().Configurators.Add(MultiTenancyMapper.CreateMappings);
            Configuration.Modules.AbpAutoMapper().Configurators.Add(ResourceMapper.CreateMappings);
            Configuration.Modules.AbpAutoMapper().Configurators.Add(TaskCenterMapper.CreateMappings);
        }

        public override void Initialize()
        {
            var thisAssembly = typeof(ProManagerApplicationModule).GetAssembly();

            IocManager.RegisterAssemblyByConvention(thisAssembly);

            Configuration.Modules.AbpAutoMapper().Configurators.Add(
                // Scan the assembly for classes which inherit from AutoMapper.Profile
                cfg => cfg.AddMaps(thisAssembly)
            );
        }

        public override void PostInitialize()
        {
            base.PostInitialize();
        }

        public override void Shutdown()
        {
            base.Shutdown();
        }
    }
}
