예제 #1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //log4net init
            LogHelper.LogInit(new ILogHelperProvider[]
            {
                new SentryLogHelperProvider()
            });

            //Register filters
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);

            #region DependenceInjection

            var builder = new ContainerBuilder();

            //RegisterAssemblyModules
            builder.RegisterAssemblyModules(BuildManager.GetReferencedAssemblies().Cast <Assembly>().ToArray());

            //ReservationDbContext
            builder.RegisterType <Models.ReservationDbContext>().SingleInstance();

            //register controllers
            builder.RegisterControllers(
                typeof(HomeController).Assembly,
                typeof(AdminLogic.Controllers.HomeController).Assembly,
                typeof(WechatAPI.Controllers.HomeController).Assembly);

            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

            // set to my own resolver
            WeihanLi.Common.DependencyResolver.SetDependencyResolver(
                new WeihanLi.Common.AutofacDependencyResolver(container));

            #endregion DependenceInjection

            // redis config
            RedisManager.AddRedisConfig(option =>
            {
                option.CachePrefix   = "ActivityReservation";
                option.ChannelPrefix = "ActivityReservation";
            });

            //register system settings
            SystemSettingsConfig.RegisterSystemSettings();
        }
예제 #2
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var builder = new ContainerBuilder();

            //register modules
            builder.RegisterAssemblyModules(BuildManager.GetReferencedAssemblies().Cast <Assembly>().ToArray());

            //ReservationDbContext
            builder.RegisterType <Models.ReservationDbContext>().SingleInstance();

            //register controllers
            builder.RegisterControllers(
                typeof(HomeController).Assembly,
                typeof(AdminLogic.Controllers.HomeController).Assembly,
                typeof(WechatAPI.Controllers.HomeController).Assembly);

            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

            // set to my own resolver
            WeihanLi.Common.DependencyResolver.SetDependencyResolver(
                new WeihanLi.Common.AutofacDependencyResolver(container));

            //log4net init
            LogHelper.LogInit(Server.MapPath("log4net.config"), new ILogProvider[]
            {
                new ExceptionlessLogProvider(),
                new SentryLogProvider()
            });

            //Register filters
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            //register system settings
            SystemSettingsConfig.RegisterSystemSettings();
        }