1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using Microsoft.AspNetCore.Builder;
|
---|
23 | using Microsoft.AspNetCore.Hosting;
|
---|
24 | using Microsoft.Extensions.DependencyInjection;
|
---|
25 | using HeuristicLab.Clients.Hive.WebJobManager.Services;
|
---|
26 | using Microsoft.Extensions.Configuration;
|
---|
27 | using HeuristicLab.Common;
|
---|
28 | using HeuristicLab.Core;
|
---|
29 | using HeuristicLab.PluginInfrastructure;
|
---|
30 | using System;
|
---|
31 | using Microsoft.AspNetCore.Mvc.Razor;
|
---|
32 | using System.Linq;
|
---|
33 | using Microsoft.CodeAnalysis;
|
---|
34 | using HeuristicLab.Clients.Hive.WebJobManager.Services.Imports;
|
---|
35 |
|
---|
36 | namespace HeuristicLab.Clients.Hive.WebJobManager
|
---|
37 | {
|
---|
38 | public class Startup
|
---|
39 | {
|
---|
40 | public IHostingEnvironment hostingEnvironment {
|
---|
41 | get; set; }
|
---|
42 | public Startup(IHostingEnvironment hostingEnvironment)
|
---|
43 | {
|
---|
44 | var builder = new ConfigurationBuilder()
|
---|
45 | .SetBasePath(hostingEnvironment.ContentRootPath);
|
---|
46 | var config = builder.Build();
|
---|
47 |
|
---|
48 | ApplicationManager.InitializeForWeb();
|
---|
49 |
|
---|
50 |
|
---|
51 | ContentManager.Initialize(new PersistenceContentManager());
|
---|
52 | //Console.WriteLine(""+ config.Get("configuration"));
|
---|
53 | this.hostingEnvironment = hostingEnvironment;
|
---|
54 | }
|
---|
55 | public void ConfigureServices(IServiceCollection services)
|
---|
56 | {
|
---|
57 |
|
---|
58 | services.AddMvc();
|
---|
59 | services.AddSession(options => {
|
---|
60 | options.IdleTimeout = TimeSpan.FromMinutes(30);
|
---|
61 | options.CookieName = ".HiveWJM";
|
---|
62 | });
|
---|
63 | services.AddSingleton<IHiveServiceLocator, HiveServiceLocatorWeb>();
|
---|
64 | services.AddSignalR();
|
---|
65 | var myAssemblies = AppDomain.CurrentDomain.GetAssemblies().Select(x => MetadataReference.CreateFromFile(x.Location)).ToList();
|
---|
66 |
|
---|
67 | services.Configure((RazorViewEngineOptions options) =>
|
---|
68 | {
|
---|
69 | var previous = options.CompilationCallback;
|
---|
70 | options.CompilationCallback = (context) =>
|
---|
71 | {
|
---|
72 | previous?.Invoke(context);
|
---|
73 |
|
---|
74 | context.Compilation = context.Compilation.AddReferences(myAssemblies);
|
---|
75 | };
|
---|
76 | });
|
---|
77 | }
|
---|
78 |
|
---|
79 | public void Configure(IApplicationBuilder app)
|
---|
80 | {
|
---|
81 | if (hostingEnvironment.IsDevelopment())
|
---|
82 | app.UseDeveloperExceptionPage();
|
---|
83 |
|
---|
84 | app.UseSession();
|
---|
85 | app.UseStaticFiles();
|
---|
86 | app.UseStatusCodePages();
|
---|
87 | app.UseMvcWithDefaultRoute();
|
---|
88 | app.UseSignalR();
|
---|
89 | }
|
---|
90 |
|
---|
91 |
|
---|
92 |
|
---|
93 | // Entry point for the application.
|
---|
94 | //public static void Main(string[] args) => WebApplication.Run<Startup>(args);
|
---|
95 | }
|
---|
96 | }
|
---|