Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Startup.cs

Last change on this file was 13862, checked in by jlodewyc, 8 years ago

#2582 Start angular OKB manager, data loaded

File size: 3.4 KB
Line 
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
22using Microsoft.AspNetCore.Builder;
23using Microsoft.AspNetCore.Hosting;
24using Microsoft.Extensions.DependencyInjection;
25using HeuristicLab.Clients.Hive.WebJobManager.Services;
26using Microsoft.Extensions.Configuration;
27using HeuristicLab.Common;
28using HeuristicLab.Core;
29using HeuristicLab.PluginInfrastructure;
30using System;
31using Microsoft.AspNetCore.Mvc.Razor;
32using System.Linq;
33using Microsoft.CodeAnalysis;
34using HeuristicLab.Clients.Hive.WebJobManager.Services.Imports;
35
36namespace 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}
Note: See TracBrowser for help on using the repository browser.