2018-04-08 01:44:42 -05:00
|
|
|
|
using System.IO;
|
2018-02-21 19:29:23 -06:00
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
2018-04-09 22:33:42 -05:00
|
|
|
|
using Microsoft.Extensions.Configuration;
|
2018-04-08 13:48:40 -05:00
|
|
|
|
using SharedLibraryCore.Interfaces;
|
2018-02-21 19:29:23 -06:00
|
|
|
|
|
|
|
|
|
namespace WebfrontCore
|
|
|
|
|
{
|
|
|
|
|
public class Program
|
|
|
|
|
{
|
2018-04-08 13:48:40 -05:00
|
|
|
|
public static IManager Manager;
|
|
|
|
|
|
2018-04-09 14:17:10 -05:00
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
throw new System.Exception("Webfront core cannot be run as a standalone application");
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-08 13:48:40 -05:00
|
|
|
|
public static void Init(IManager mgr)
|
2018-02-21 19:29:23 -06:00
|
|
|
|
{
|
2018-04-08 13:48:40 -05:00
|
|
|
|
Manager = mgr;
|
|
|
|
|
BuildWebHost().Run();
|
2018-04-08 01:44:42 -05:00
|
|
|
|
}
|
2018-03-09 02:01:12 -06:00
|
|
|
|
|
2018-04-09 22:33:42 -05:00
|
|
|
|
public static IWebHost BuildWebHost()
|
|
|
|
|
{
|
|
|
|
|
var config = new ConfigurationBuilder()
|
|
|
|
|
.AddEnvironmentVariables()
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
return new WebHostBuilder()
|
2018-04-08 16:50:58 -05:00
|
|
|
|
#if DEBUG
|
|
|
|
|
.UseContentRoot(Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), @"..\..\..\..\", "WebfrontCore")))
|
|
|
|
|
#else
|
2018-10-06 15:31:05 -05:00
|
|
|
|
.UseContentRoot(SharedLibraryCore.Utilities.OperatingDirectory)
|
2018-04-08 16:50:58 -05:00
|
|
|
|
#endif
|
2018-04-19 00:48:14 -05:00
|
|
|
|
.UseUrls(Manager.GetApplicationSettings().Configuration().WebfrontBindUrl)
|
2018-04-08 01:44:42 -05:00
|
|
|
|
.UseKestrel()
|
2018-02-21 19:29:23 -06:00
|
|
|
|
.UseStartup<Startup>()
|
|
|
|
|
.Build();
|
2018-04-09 22:33:42 -05:00
|
|
|
|
}
|
2018-02-21 19:29:23 -06:00
|
|
|
|
}
|
|
|
|
|
}
|