コード例 #1
0
ファイル: AutofacConfig.cs プロジェクト: rkemr/ioc
 public static IContainer BuildContainer(ContainerBuilder builder)
 {
     return builder
         .RegisterServices()
         .RegisterControllers()
         .Build();
 }
コード例 #2
0
        private IContainer CreateContainer()
        {
            var builder = new ContainerBuilder();
            builder.RegisterServices(Assembly.GetExecutingAssembly());

            var container = builder.Build();
            return new AutofacAdapter(container);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: ricklxm/Griffin.Framework
 private static AutofacAdapter BuildContainer()
 {
     var containerBuilder = new ContainerBuilder();
     containerBuilder.RegisterServices(Assembly.GetExecutingAssembly());
     var container = containerBuilder.Build();
     var adapter = new AutofacAdapter(container);
     return adapter;
 }
コード例 #4
0
ファイル: Worker1.cs プロジェクト: WIBORI/api-template
        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();
        }
コード例 #5
0
        /// <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;
        }