IW4M-Admin/WebfrontCore/Program.cs

44 lines
1.3 KiB
C#
Raw Normal View History

2018-04-08 02:44:42 -04:00
using System.IO;
using System.Threading;
using System.Threading.Tasks;
2018-02-21 20:29:23 -05:00
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using SharedLibraryCore.Interfaces;
2018-02-21 20:29:23 -05:00
namespace WebfrontCore
{
public class Program
{
public static IManager Manager;
static void Main()
{
throw new System.Exception("Webfront core cannot be run as a standalone application");
}
public static Task Init(IManager mgr, CancellationToken cancellationToken)
2018-02-21 20:29:23 -05:00
{
Manager = mgr;
return BuildWebHost().RunAsync(cancellationToken);
2018-04-08 02:44:42 -04:00
}
2018-03-09 03:01:12 -05:00
private static IWebHost BuildWebHost()
{
var config = new ConfigurationBuilder()
.AddEnvironmentVariables()
.Build();
return new WebHostBuilder()
#if DEBUG
.UseContentRoot(Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), @"..\..\..\..\", "WebfrontCore")))
#else
.UseContentRoot(SharedLibraryCore.Utilities.OperatingDirectory)
#endif
.UseUrls(Manager.GetApplicationSettings().Configuration().WebfrontBindUrl)
2018-04-08 02:44:42 -04:00
.UseKestrel()
2018-02-21 20:29:23 -05:00
.UseStartup<Startup>()
.Build();
}
2018-02-21 20:29:23 -05:00
}
}