IW4M-Admin/WebfrontCore/Program.cs

49 lines
1.8 KiB
C#
Raw Permalink Normal View History

using System;
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 Microsoft.Extensions.DependencyInjection;
using Serilog;
using SharedLibraryCore.Interfaces;
using WebfrontCore.Middleware;
2018-02-21 20:29:23 -05:00
namespace WebfrontCore
{
public class Program
{
public static IManager Manager;
public static IServiceCollection Services;
public static IServiceProvider ApplicationServiceProvider;
public static Task Init(IManager mgr, IServiceProvider existingServiceProvider, IServiceCollection services, CancellationToken cancellationToken)
2018-02-21 20:29:23 -05:00
{
Services = services;
Manager = mgr;
ApplicationServiceProvider = existingServiceProvider;
var config = Manager.GetApplicationSettings().Configuration();
Manager.MiddlewareActionHandler.Register(null, new CustomCssAccentMiddlewareAction("#007ACC", "#fd7e14", config.WebfrontPrimaryColor, config.WebfrontSecondaryColor), "custom_css_accent");
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
}
}