public static IContainer BuildContainer(ContainerBuilder builder) { return builder .RegisterServices() .RegisterControllers() .Build(); }
private IContainer CreateContainer() { var builder = new ContainerBuilder(); builder.RegisterServices(Assembly.GetExecutingAssembly()); var container = builder.Build(); return new AutofacAdapter(container); }
private static AutofacAdapter BuildContainer() { var containerBuilder = new ContainerBuilder(); containerBuilder.RegisterServices(Assembly.GetExecutingAssembly()); var container = containerBuilder.Build(); var adapter = new AutofacAdapter(container); return adapter; }
private IContainer InitContainer() { var dbConnectionString = ConfigurationManager.ConnectionStrings["DbContext"].ConnectionString; var serviceBusConnectionString = ConfigurationManager.ConnectionStrings["ServiceBus"].ConnectionString; var builder = new ContainerBuilder(); builder.RegisterRepositories(dbConnectionString); builder.RegisterServices(); builder.RegisterNimbus(serviceBusConnectionString); return builder.Build(); }
/// <summary> /// Registers the configuration to the application /// </summary> public static IContainer Register() { var dbConnectionString = ConfigurationManager.ConnectionStrings["DbContext"].ConnectionString; var seviceBusConnectionString = ConfigurationManager.ConnectionStrings["ServiceBus"].ConnectionString; var builder = new ContainerBuilder(); builder.RegisterApiControllers(Assembly.GetExecutingAssembly()); builder.RegisterRepositories(dbConnectionString); builder.RegisterExternalServices(); builder.RegisterServices(); builder.RegisterDummyServices(); builder.RegisterNimbus(seviceBusConnectionString); var container = builder.Build(); // Create the depenedency resolver. var resolver = new AutofacWebApiDependencyResolver(container); // Configure Web API with the dependency resolver. GlobalConfiguration.Configuration.DependencyResolver = resolver; return container; }