Beispiel #1
0
        public void Configuration(IAppBuilder app)
        {
            var assemblies = BuildManager.GetReferencedAssemblies().Cast <Assembly>().ToArray();

            WebApp = new WebApp();

            var wcc = new WebContainerConfiguration(WebApp.Context);

            wcc.RegisterAllTypes();

            WebApp.BootstrapMvc(assemblies);

            app.UseDataAccess(WebApp.Context);

            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);

            HttpConfiguration config = new HttpConfiguration
            {
                DependencyResolver = new SimpleInjectorWebApiDependencyResolver(WebApp.GetContainer())
            };

            WebApiConfig.Register(config);

            app.UseWebApi(config);
        }
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            WebApp = new WebApp();

            var wcc = new WebContainerConfiguration(WebApp.Context);

            wcc.RegisterAllTypes();

            // setup web dependency injection
            Assembly[] assemblies = BuildManager.GetReferencedAssemblies().Cast <Assembly>().ToArray();
            WebApp.BootstrapMvc(assemblies);

            config.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(WebApp.GetContainer());

            WebApi.WebApiConfig.Register(config);
        }