Exemple #1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

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

            FluentValidationModelValidatorProvider.Configure();
            IUnityContainer container = new UnityContainer();

            UnityRegistrar.Register(container);

            AutoMapperInitializer.Initialise();

            ControllerBuilder.Current.SetControllerFactory(new UnityControllerFactory(container));
            DummyDataCreator.PopulateRepository();
        }
Exemple #2
0
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            // Configure the Dependency Resolver
            var registrar = new UnityRegistrar();
            var container = new UnityContainer();

            container = registrar.Register(container);
            config.DependencyResolver = new UnityResolver(container);

            // Configure Web API to use only bearer token authentication.
            config.SuppressDefaultHostAuthentication();
            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
        }