WebApiCoreProgram

    0

    0

    The following code creates a host builder and registers a module with it. The module AutofacBusinessModule allows the creation of services.

    using System;
    using System.Linq;
    using Microsoft.Extensions.Logging;
    using System.Collections.Generic;
    using Business.DependencyResolvers.Autofac;
    using Microsoft.Extensions.Hosting;
    using Autofac;
    using Autofac.Extensions.DependencyInjection;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.Extensions.Configuration;
    using System.Threading.Tasks;
    
    
    
    namespace WebAPI
    {
      public class Program
      {
        public static void Main(string[] args)
        {
          CreateHostBuilder(args).Build().Run();
        }
    
        public static IHostBuilder CreateHostBuilder(string[] args) =>
          Host.CreateDefaultBuilder(args)
            .UseServiceProviderFactory(new AutofacServiceProviderFactory())
            .ConfigureContainer<ContainerBuilder>(builder =>
              {
                builder.RegisterModule(new AutofacBusinessModule());
              })
            .ConfigureWebHostDefaults(webBuilder =>
            {
              webBuilder.UseStartup<Startup>();
            });
      }
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.