Example #1
0
        /// <summary>
        /// Applications the start.
        /// </summary>
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);
            var config  = GlobalConfiguration.Configuration;
            var builder = new ServiceLocatorWebFluent().CreateContainer(config).Build();

            // Set the dependency resolver to be Autofac.
            config.DependencyResolver = new AutofacWebApiDependencyResolver(builder.GetRawContainer());
        }
Example #2
0
        // This method gets called by the runtime. Use this method to add services to the container
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddApplicationInsightsTelemetry(Configuration);

            services.AddMvc();

            services.AddCors();
            services.AddOptions();

            var serviceLocator = new ServiceLocatorWebFluent().CreateContainer().Build();

            return(serviceLocator.Resolve <IServiceProvider>());
        }