ILifetimeScope BuildContainer()
 {
     var builder = new ContainerBuilder();
     builder.RegisterControllers(typeof(MvcApplication).Assembly);
     builder.UseDD4T();
     return builder.Build();
 }
        public static void UseDD4TWebApi(this IAppBuilder appBuilder, ContainerBuilder builder, HttpConfiguration config)
        {
            builder.RegisterApiControllers(typeof(AppBuilderExtensions).Assembly);
            builder.UseDD4T();

            var container = builder.Build();

            config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
            config.MapHttpAttributeRoutes();

            appBuilder.UseAutofacMiddleware(container);
            appBuilder.UseAutofacWebApi(config);
            appBuilder.UseWebApi(config);
        }