using Autofac;
using Autofac.Integration.Mvc;
using CommonClass.Factory;

namespace CmdjyHisFront
{
    public class IocFactory
    {
        private static IOCFactory _iocFactory = null;
        /// <summary>
        /// 控制反转容器工厂
        /// </summary>
        public static ILifetimeScope Factory {
            get {
                if(_iocFactory == null) {
                    _iocFactory = new IOCFactory();
                    _iocFactory.BeforeBuild += _iocFactory_BeforeBuild;
                    _iocFactory.Init();
                }
                return _iocFactory.Container.BeginLifetimeScope();
            }
        }

        private static void _iocFactory_BeforeBuild(IOCFactory arg1,ContainerBuilder arg2) {
            arg2.RegisterControllers();
        }
    }
}