using APT.BaseData.Domain.IServices;
using APT.BaseData.Domain.IServices.BD;
using APT.BaseData.Domain.IServices.BS;
using APT.BaseData.Domain.IServices.EX;
using APT.BaseData.Domain.IServices.FM;
using APT.BaseData.Domain.IServices.Platform;
using APT.BaseData.Services.DomainServices;
using APT.BaseData.Services.Services.BD;
using APT.BaseData.Services.Services.BS;
using APT.BaseData.Services.Services.EX;
using APT.BaseData.Services.Services.FM;
using APT.BaseData.Services.Services.Platform;
using APT.BaseData.Services.Sys;
using Autofac;

namespace APT.FO.WebApi.App_Start
{
    public static class DIConfig
    {
        public static void RegisterComponents(this ContainerBuilder builder)
        {
            APT.Utility.BaseServiceRegister.RegisterComponents(builder);

            builder.RegisterMesService();
            builder.RegisterBaseService();
        }

        private static void RegisterBaseService(this ContainerBuilder builder)
        {
            builder.RegisterType<PFCodeRuleSerialService>().As<IPFCodeRuleSerialService>().InstancePerLifetimeScope();
            builder.RegisterType<PFApproveCallBackMTService>().As<IPFApproveCallBackMTService>().InstancePerLifetimeScope();
            builder.RegisterType<PFApproveCallBackSEService>().As<IPFApproveCallBackSEService>().InstancePerLifetimeScope();
            builder.RegisterType<PFApproveCallBackService>().As<IPFApproveCallBackService>().InstancePerLifetimeScope();
            builder.RegisterType<PFCodeRuleService>().As<IPFCodeRuleService>().InstancePerLifetimeScope();
            builder.RegisterType<PFFormService>().As<IPFFormService>().InstancePerLifetimeScope();
            builder.RegisterType<PFLabelService>().As<IPFLabelService>().InstancePerLifetimeScope();
            builder.RegisterType<PFMenuService>().As<IPFMenuService>().InstancePerLifetimeScope();
            builder.RegisterType<PFAppMenuService>().As<IPFAppMenuService>().InstancePerLifetimeScope();
            builder.RegisterType<FMOrganizationService>().As<IFMOrganizationService>().InstancePerLifetimeScope();
            builder.RegisterType<EntityOperateService>().As<IEntityOperateService>().InstancePerLifetimeScope();
            builder.RegisterType<MesLogService>().As<IMesLog>().InstancePerLifetimeScope();
            builder.RegisterType<PFLastVersionService>().As<IPFLastVersionService>().InstancePerLifetimeScope();
        }

        private static void RegisterMesService(this ContainerBuilder builder)
        {
            //builder.RegisterType<FMWorkstageCalendarService>().As<IFMWorkstageCalendarService>().InstancePerLifetimeScope();
            builder.RegisterType<PFSysLogService>().As<IPFSysLogService>().InstancePerLifetimeScope();
            builder.RegisterType<FMUserService>().As<IFMUserService>().InstancePerLifetimeScope();
            builder.RegisterType<FMRoleService>().As<IFMRoleService>().InstancePerLifetimeScope();
            builder.RegisterType<NotificationService>().As<IFMNotificatoinService>().InstancePerLifetimeScope();
            builder.RegisterType<FMImportService>().As<IFMImportService>().InstancePerLifetimeScope();
            builder.RegisterType<PFFlowService>().As<IPFFlowService>().InstancePerLifetimeScope();
            builder.RegisterType<FMFlowPermitService>().As<IFMFlowPermitService>().InstancePerLifetimeScope();
            builder.RegisterType<FMDepartmentService>().As<IFMDepartmentService>().InstancePerLifetimeScope();
            builder.RegisterType<FMAutoPrintRecordService>().As<IFMAutoPrintRecordService>().InstancePerLifetimeScope();
            builder.RegisterType<ExtConnConfigService>().As<IExtConnConfigService>().InstancePerLifetimeScope();
            builder.RegisterType<FMNotificationTaskService>().As<IFMNotificationTaskService>().InstancePerLifetimeScope();
            builder.RegisterType<BSSafeCheckService>().As<IBSSafeCheckService>().InstancePerLifetimeScope();
            builder.RegisterType<BSOperateLogService>().As<IBSOperateLogService>().InstancePerLifetimeScope();
        }
    }
}
