Пример #1
0
        protected void Application_Start()
        {
            var builder = AutofacConfig.ConfigureContainer();

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

            var config = AutoMapperConfig.ConfigureContainer(AutoMapperConfigHelper.AddWebMappings());

            builder.Register((x) => config.CreateMapper()).As(typeof(IMapper));

            builder.RegisterControllers(typeof(MvcApplication).Assembly);
            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }