using Autofac;
using JiaZhiQuan.Common.Config;
using JiaZhiQuan.Common.Messaging;
using JiaZhiQuan.Common.Region;
using System;
using System.Collections.Generic;
using System.Text;

namespace JiaZhiQuan.Common.IoC
{
    public class CommonModule : Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            if (!ConfigFromDbConfig.GetFromConfig().Disabled)
            {
                builder.RegisterType<ConfigRefreshScheduleService>().AsSelf().SingleInstance();
            }
            if (!string.IsNullOrEmpty(KafkaClientConfig.GetFromConfig().BootstrapServers))
            {
                builder.RegisterType<Producer>().AsSelf().SingleInstance();
            }
            
            builder.RegisterType<ConfigFromDb>().AsSelf().SingleInstance();
            builder.RegisterType<RegionHelper>().AsSelf().SingleInstance();

            base.Load(builder);
        }
    }
}
