Esempio n. 1
0
        private void RegisterAutoFacComponents()
        {
            var builder = new ContainerBuilder();

            ComponentRegistration.RegisterService(builder);

            builder.RegisterControllers(Assembly.GetExecutingAssembly());
            builder.RegisterApiControllers(Assembly.GetExecutingAssembly());

            IContainer container = builder.Build(ContainerBuildOptions.IgnoreStartableComponents);

            var resolver = new AutofacWebApiDependencyResolver(container);

            GlobalConfiguration.Configuration.DependencyResolver = resolver;
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }