Free cookie consent management tool by TermsFeed Policy Generator

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

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

#2582 RC2 migration fixed. OKB query implemented. Preparing for OKB manager

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;
34
35namespace HeuristicLab.Clients.Hive.WebJobManager
36{
37    public class Startup
38    {
39        public IHostingEnvironment hostingEnvironment {
40            get; set; }
41        public Startup(IHostingEnvironment hostingEnvironment)
42        {
43            var builder = new ConfigurationBuilder()
44                .SetBasePath(hostingEnvironment.ContentRootPath);
45            var config = builder.Build();
46
47            ApplicationManager.InitializeForWeb();
48
49
50            ContentManager.Initialize(new PersistenceContentManager());
51            //Console.WriteLine(""+ config.Get("configuration"));
52            this.hostingEnvironment = hostingEnvironment;
53        }
54         public void ConfigureServices(IServiceCollection services)
55        {
56
57            services.AddMvc();
58            services.AddSession(options => {
59                options.IdleTimeout = TimeSpan.FromMinutes(30);
60                options.CookieName = ".HiveWJM";
61            });
62            services.AddSingleton<IHiveServiceLocator, HiveServiceLocatorWeb>();
63            services.AddSignalR();
64            var myAssemblies = AppDomain.CurrentDomain.GetAssemblies().Select(x => MetadataReference.CreateFromFile(x.Location)).ToList();
65
66            services.Configure((RazorViewEngineOptions options) =>
67            {
68                var previous = options.CompilationCallback;
69                options.CompilationCallback = (context) =>
70                {
71                    previous?.Invoke(context);
72
73                    context.Compilation = context.Compilation.AddReferences(myAssemblies);
74                };
75            });
76        }
77
78      public void Configure(IApplicationBuilder app)
79        {
80            if (hostingEnvironment.IsDevelopment())
81                app.UseDeveloperExceptionPage();
82           
83            app.UseSession();
84            app.UseStaticFiles();
85            app.UseStatusCodePages();
86            app.UseMvcWithDefaultRoute();
87            app.UseSignalR();
88        }
89
90
91
92        // Entry point for the application.
93        //public static void Main(string[] args) => WebApplication.Run<Startup>(args);
94    }
95}
Note: See TracBrowser for help on using the repository browser.