2018-08-28 21:45:56 +00:00
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BotSharp.WebHost
|
|
|
|
|
|
{
|
|
|
|
|
|
public class Program
|
|
|
|
|
|
{
|
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
|
{
|
|
|
|
|
|
BuildWebHost(args).Run();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static IWebHost BuildWebHost(string[] args) =>
|
|
|
|
|
|
Microsoft.AspNetCore.WebHost.CreateDefaultBuilder(args)
|
|
|
|
|
|
.ConfigureAppConfiguration((hostingContext, config) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var env = hostingContext.HostingEnvironment;
|
2018-09-13 21:52:19 +00:00
|
|
|
|
string dir = Path.GetFullPath(env.ContentRootPath);
|
|
|
|
|
|
string settingsFolder = Path.Combine(dir, "Settings");
|
|
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(settingsFolder))
|
|
|
|
|
|
{
|
|
|
|
|
|
dir = Path.GetFullPath(env.ContentRootPath + "/..");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
settingsFolder = Path.Combine(dir, "Settings");
|
|
|
|
|
|
Console.WriteLine($"Settings folder: {settingsFolder}");
|
|
|
|
|
|
var settings = Directory.GetFiles(settingsFolder, "*.json");
|
2018-08-28 21:45:56 +00:00
|
|
|
|
settings.ToList().ForEach(setting =>
|
|
|
|
|
|
{
|
2018-09-13 21:52:19 +00:00
|
|
|
|
Console.WriteLine($"Read {setting}");
|
2018-08-28 21:45:56 +00:00
|
|
|
|
config.AddJsonFile(setting, optional: false, reloadOnChange: true);
|
|
|
|
|
|
});
|
|
|
|
|
|
})
|
|
|
|
|
|
.UseUrls("http://0.0.0.0:5000")
|
|
|
|
|
|
.UseStartup<Startup>()
|
|
|
|
|
|
.Build();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|