public static IApplicationHost Build(this IApplicationHostBuilder hostBuilder)
        {
            //string environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");

            //if (String.IsNullOrWhiteSpace(environment))
            //    throw new ArgumentNullException("Environment not found in ASPNETCORE_ENVIRONMENT");

            var builder = new ConfigurationBuilder()
                          .SetBasePath(Path.Combine(Directory.GetCurrentDirectory()))
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          //.AddJsonFile($"appsettings.Development.json", optional: true, reloadOnChange: true)
            ;

            IConfiguration configuration = builder.Build();

            hostBuilder.ApplicationFramework.Services.AddTransient((sp) => configuration);

            IBootstrapper bootstrapper = (IBootstrapper)Activator.CreateInstance(hostBuilder.ApplicationFramework.BootstrapperType, new[] { configuration });

            bootstrapper.ConfigureServices(hostBuilder.ApplicationFramework.Services);

            hostBuilder.ApplicationFramework.BuildServiceProvider();

            ILoggingBuilder loggingBuilder = hostBuilder.ApplicationFramework.ServiceProvider.GetService <ILoggingBuilder>();

            bootstrapper.Configure(hostBuilder, loggingBuilder);

            return(new DefaultApplicationHost(hostBuilder.ApplicationFramework));
        }
        public static IApplicationHostBuilder UseStartup <TStartup>(this IApplicationHostBuilder hostBuilder) where TStartup : IBootstrapper
        {
            hostBuilder.ApplicationFramework.SetBootstrapperType <TStartup>();

            return(hostBuilder);
        }
        // This method gets called by the runtime. Use this method to configure the request pipeline.
        public void Configure(IApplicationHostBuilder hostBuilder, ILoggingBuilder loggingBuilder)
        {
            hostBuilder.ApplicationFramework.SetEntryPointType <WelcomeLetterController>();

            loggingBuilder?.AddConsole();
        }