Exemple #1
0
        public void TestCase1()
        {
            AutofacHelper.InitAutofacContainer();
            var fun = AutofacHelper.GetInstance <IFun>();

            Assert.AreEqual("Fun1", fun.GetInstanceType());
        }
Exemple #2
0
        public void TestCase2()
        {
            AutofacHelper.InitAutofacContainer("../../Ioc/Autofac.xml");
            var fun = AutofacHelper.GetInstance <IFun>();

            Assert.AreEqual("Fun2", fun.GetInstanceType());
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            //处理视图引擎
            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new RazorViewEngine());

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //系统其他初始化
            var configRootPath = Server.MapPath("~/Config/");

            //IOC
            AutofacHelper.InitAutofacContainer(Path.Combine(configRootPath, "Autofac/AutofacConfig.xml"));
            //日志
            Log4NetHelper.InitLog4Net(Path.Combine(configRootPath, "Log4net/Log4Net.xml"));
        }