|
|
@ -20,9 +20,9 @@ namespace AOC2021.Controllers
|
|
|
|
[HttpPost]
|
|
|
|
[HttpPost]
|
|
|
|
[Consumes("text/plain")]
|
|
|
|
[Consumes("text/plain")]
|
|
|
|
[Route("day1")]
|
|
|
|
[Route("day1")]
|
|
|
|
public AOCResponse Day(AOCVersion version, [FromBody] string input)
|
|
|
|
public AOCResponse Day(AOCVersion version, [FromBody] string input, bool IgnoreLogMessages = false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AOCRequest request = new AOCRequest() { Input = input, Version = version };
|
|
|
|
AOCRequest request = new AOCRequest() { Input = input, Version = version, IgnoreLogMessages = IgnoreLogMessages };
|
|
|
|
var splitRoute = this.ControllerContext.HttpContext.Request.Path.ToString().Split("/");
|
|
|
|
var splitRoute = this.ControllerContext.HttpContext.Request.Path.ToString().Split("/");
|
|
|
|
string requestedRoute = splitRoute[splitRoute.Length - 1]; //Get the last endpoint value.
|
|
|
|
string requestedRoute = splitRoute[splitRoute.Length - 1]; //Get the last endpoint value.
|
|
|
|
return GetAOCDay(requestedRoute).ExecuteDay(request);
|
|
|
|
return GetAOCDay(requestedRoute).ExecuteDay(request);
|
|
|
@ -30,17 +30,17 @@ namespace AOC2021.Controllers
|
|
|
|
|
|
|
|
|
|
|
|
private AOCDay GetAOCDay(string route)
|
|
|
|
private AOCDay GetAOCDay(string route)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IAOCService day = null;
|
|
|
|
AOCDay day = null;
|
|
|
|
var type = typeof(AOCDay);
|
|
|
|
var type = typeof(AOCDay);
|
|
|
|
var types = AppDomain.CurrentDomain.GetAssemblies()
|
|
|
|
var types = AppDomain.CurrentDomain.GetAssemblies()
|
|
|
|
.SelectMany(s => s.GetTypes())
|
|
|
|
.SelectMany(s => s.GetTypes())
|
|
|
|
.Where(p => type.IsAssignableFrom(p) && !p.IsInterface && !p.IsAbstract);
|
|
|
|
.Where(p => type.IsAssignableFrom(p) && !p.IsInterface && !p.IsAbstract);
|
|
|
|
foreach (var x in types)
|
|
|
|
foreach (var x in types)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Console.WriteLine(x.Name.ToLower());
|
|
|
|
|
|
|
|
if (x.Name.ToLower() == route.ToLower())
|
|
|
|
if (x.Name.ToLower() == route.ToLower())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
day = (IAOCService)Activator.CreateInstance(x);
|
|
|
|
day = (AOCDay) (IAOCService)Activator.CreateInstance(x);
|
|
|
|
|
|
|
|
day.SetLogger(this._logger);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|