#region License Information
/* HeuristicLab
* Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using HeuristicLab.Clients.Hive.WebJobManager.Services;
using Microsoft.Extensions.Configuration;
using HeuristicLab.Common;
using HeuristicLab.Core;
using HeuristicLab.PluginInfrastructure;
using System;
using Microsoft.AspNetCore.Mvc.Razor;
using System.Linq;
using Microsoft.CodeAnalysis;
using HeuristicLab.Clients.Hive.WebJobManager.Services.Imports;
namespace HeuristicLab.Clients.Hive.WebJobManager
{
public class Startup
{
public IHostingEnvironment hostingEnvironment {
get; set; }
public Startup(IHostingEnvironment hostingEnvironment)
{
var builder = new ConfigurationBuilder()
.SetBasePath(hostingEnvironment.ContentRootPath);
var config = builder.Build();
ApplicationManager.InitializeForWeb();
ContentManager.Initialize(new PersistenceContentManager());
//Console.WriteLine(""+ config.Get("configuration"));
this.hostingEnvironment = hostingEnvironment;
}
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddSession(options => {
options.IdleTimeout = TimeSpan.FromMinutes(30);
options.CookieName = ".HiveWJM";
});
services.AddSingleton();
services.AddSignalR();
var myAssemblies = AppDomain.CurrentDomain.GetAssemblies().Select(x => MetadataReference.CreateFromFile(x.Location)).ToList();
services.Configure((RazorViewEngineOptions options) =>
{
var previous = options.CompilationCallback;
options.CompilationCallback = (context) =>
{
previous?.Invoke(context);
context.Compilation = context.Compilation.AddReferences(myAssemblies);
};
});
}
public void Configure(IApplicationBuilder app)
{
if (hostingEnvironment.IsDevelopment())
app.UseDeveloperExceptionPage();
app.UseSession();
app.UseStaticFiles();
app.UseStatusCodePages();
app.UseMvcWithDefaultRoute();
app.UseSignalR();
}
// Entry point for the application.
//public static void Main(string[] args) => WebApplication.Run(args);
}
}